How can I calculate the center of a circle by given 3 points that are on the border line?
Printable View
How can I calculate the center of a circle by given 3 points that are on the border line?
Nevermind; got it...
VB Code:
Public Function GetCenter(p1 As tPoint, p2 As tPoint, p3 As tPoint) As tPoint Dim Det As Single Dim Temp As Single Dim x1 As Single, y1 As Single Dim x2 As Single, y2 As Single Dim x3 As Single, y3 As Single Dim bc As Single Dim cd As Single x1 = p1.X: y1 = p1.Y x2 = p2.X: y2 = p2.Y x3 = p3.X: y3 = p3.Y Temp = x2 * x2 + y2 * y2 bc = (x1 * x1 + y1 * y1 - Temp) / 2 cd = (Temp - x3 * x3 - y3 * y3) / 2 Det = 1 / ( (x1 - x2) * (y2 - y3) - (x2 - x3) * (y1 - y2) ) GetCenter.X = (bc * (y2 - y3) - cd * (y1 - y2)) * Det GetCenter.Y = ((x1 - x2) * cd - (x2 - x3) * bc) * Det End Function