Centre and radius of a circle passing through 3 points in a plane: Difference between revisions
Content added Content deleted
(Added Dart) |
m (→{{header|Phix}}: added an assertion) |
||
Line 152: | Line 152: | ||
e2f2 = e*e+f*f, ca = c-a, fd = f-d, |
e2f2 = e*e+f*f, ca = c-a, fd = f-d, |
||
cx = 0.5*(a2b2*fd+c2d2*bf+e2f2*db)/(a*fd+c*bf+e*db), |
cx = 0.5*(a2b2*fd+c2d2*bf+e2f2*db)/(a*fd+c*bf+e*db), |
||
cy = 0.5*(a2b2*ec+c2d2*ae+e2f2*ca)/(b*ec+d*ae+f*ca) |
cy = 0.5*(a2b2*ec+c2d2*ae+e2f2*ca)/(b*ec+d*ae+f*ca) |
||
-- any one of these should do / be nearly identical: |
|||
⚫ | |||
sequence r123 = {power(cx-a,2)+power(cy-b,2), |
|||
power(cx-c,2)+power(cy-d,2), |
|||
⚫ | |||
assert((max(r123)-min(r123))<1e-12) |
|||
atom r = sqrt(average(r123)) |
|||
return {{cx,cy},r} |
return {{cx,cy},r} |
||
end function |
end function |