Could somebody please show code which would do this quickly? Assume we get three points p1, p2, p3 in left-->right order. Thus, the solution should also check whether or not the circle is valid, ie (p1, p2, p3) are counter-clockwise.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
To calculate the circle parameters, have a look at:
http://paulbourke.net/geometry/circlesphere/ Look for "Equation of a Circle from 3 Points (2 dimensions)"
to determine orientation, you can use the polygon area formula:
http://paulbourke.net/geometry/polygonmesh/ Look for "Calculating the area and centroid of a polygon"
Please tell me if you need this in an specific programming language.
回答2:
Connect any two points on the circle and you have a chord.
The perpendicular bisector of a chord must pass through the center.
The intersection of the bisectors of two chords will be the center.
Remainder (reduction to form for most efficient calculation) is left as an exercise for the reader...