Centre and radius of a circle passing through 3 points in a plane: Difference between revisions
Centre and radius of a circle passing through 3 points in a plane (view source)
Revision as of 00:22, 21 February 2024
, 2 months ago→{{header|Phix}}: added an assertion
(Added Dart) |
m (→{{header|Phix}}: added an assertion) |
||
Line 152:
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),
cy = 0.5*(a2b2*ec+c2d2*ae+e2f2*ca)/(b*ec+d*ae+f*ca)
-- any one of these should do / be nearly identical:
r = sqrt(power(cx-e,2)+power(cy-f,2))▼
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}
end function
|