Calculate Center and Radius of Circle from 3 points on it

匿名 (未验证) 提交于 2019-12-03 01:31:01

问题:

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!