# Difference between revisions of "Least-squares circle fitting"

From JSXGraph Wiki

Jump to navigationJump to searchA WASSERMANN (talk | contribs) |
A WASSERMANN (talk | contribs) |
||

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> |