Private Sub FindCircle(ByVal ax As Single, ByVal ay As _
Single, ByVal bx As Single, ByVal by As Single, ByVal _
cx As Single, ByVal cy As Single, ByRef ox As Single, _
ByRef oy As Single, ByRef radius As Single)
Dim x1 As Single
Dim y1 As Single
Dim dx1 As Single
Dim dy1 As Single
Dim x2 As Single
Dim y2 As Single
Dim dx2 As Single
Dim dy2 As Single
Dim dx As Single
Dim dy As Single
' Get the perpendicular bisector of (x1, y1) and (x2,
' y2).
x1 = (bx + ax) / 2
y1 = (by + ay) / 2
dy1 = bx - ax
dx1 = -(by - ay)
' Get the perpendicular bisector of (x2, y2) and (x3,
' y3).
x2 = (cx + bx) / 2
y2 = (cy + by) / 2
dy2 = cx - bx
dx2 = -(cy - by)
' See where the lines intersect.
ox = (y1 * dx1 * dx2 + x2 * dx1 * dy2 - x1 * dy1 * dx2 _
- y2 * dx1 * dx2) _
/ (dx1 * dy2 - dy1 * dx2)
oy = (ox - x1) * dy1 / dx1 + y1
dx = ox - ax
dy = oy - ay
radius = Sqr(dx * dx + dy * dy)
End Sub
|