這裏就是我面臨的問題,實際的代碼摘錄:大數被轉換爲NaN
var p = {x:400, y:100, z:100};
var c = {x:250, y:250, z:100};
var o = {x:250, y:250, z:250};
var ta = 1;
var r1 = 212.13203435596427;
var r2 = 259.8076211353316;
var b1 = Math.round(2*r1*r1*(1 - Math.cos(ta)) - r2*r2 + (o.x+p.x)*(o.x-p.x) + (o.y+p.y)*(o.y-p.y) + (o.z+p.z)*(o.z-p.z));
var b2 = Math.round(r1*r1*(1 - 2*Math.cos(ta)) + (c.x+p.x)*(c.x-p.x) + (c.y+p.y)*(c.y-p.y) + (c.z+p.z)*(c.z-p.z));
var b3 = Math.round((r2+r1)*(r2-r1) + (c.x+o.x)*(c.x-o.x) + (c.y+o.y)*(c.y-o.y) + (c.z+o.z)*(c.z-o.z));
var A = [ [2*(o.x - p.x), 2*(o.y - p.y), 2*(o.z - p.z)],
[2*(c.x - p.x), 2*(c.y - p.y), 2*(c.z - p.z)],
[2*(c.x - o.x), 2*(c.y - o.y), 2*(c.z - o.z)]
];
A[0][3] = b1;
A[1][3] = b2;
A[2][3] = b3;
console.log(A[0]);
console.log(A[1]);
console.log(A[2]);
console.log(A);
由於尚未代碼工作非常細:
然後我在上面的代碼之後加上這一行。
var sol = gauss(A);
現在,當我在控制檯上運行此,:
請注意四個值沒有被僱用爲NaN不像第一張截圖。爲什麼會發生這種情況,我如何防止這種情況發生?
萬一你認爲錯誤是在高斯()函數這裏的來源:[鏈接](http://martin-thoma.com/solving-linear-equations-with-gaussian-elimination/#tocAnchor-1- 4) – 2015-03-03 12:45:48
高斯做什麼?請張貼代碼 – Tschallacka 2015-03-03 12:45:52
將gauss()源放在問題中。這肯定來自該功能。 – enguerranws 2015-03-03 12:46:58