Least-squares circle fitting: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 13: | Line 13: | ||
} | } | ||
brd.unsuspendUpdate(); | brd.unsuspendUpdate(); | ||
var M = [], y = [], MT, B, c, coeffs, len; | |||
len = p.length; | |||
for (i=0;i<len;i++) { | |||
M.push([p[i].X(), p[i].Y(), 1.0]); | |||
y.push(p[i].X()*p[i].X() + p[i].Y()*p[i].Y()); | |||
} | |||
MT = JXG.Math.transpose(M); | |||
B = JXG.Math.matMatMult(MT, M); | |||
c = JXG.Math.matVecMult(MT, y); | |||
coeffs = JXG.Math.Numerics.Gauss(B, c); | |||
alert(coeffs.toString()); | |||
</jsxgraph> | </jsxgraph> |