Results 1 to 2 of 2

Thread: [Solved] Circle Center

  1. #1

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    [Solved] Circle Center

    How can I calculate the center of a circle by given 3 points that are on the border line?
    Last edited by Fox; Aug 11th, 2004 at 01:54 AM.

  2. #2

    Thread Starter
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Nevermind; got it...

    VB Code:
    1. Public Function GetCenter(p1 As tPoint, p2 As tPoint, p3 As tPoint) As tPoint
    2.     Dim Det As Single
    3.     Dim Temp As Single
    4.    
    5.     Dim x1 As Single, y1 As Single
    6.     Dim x2 As Single, y2 As Single
    7.     Dim x3 As Single, y3 As Single
    8.    
    9.     Dim bc As Single
    10.     Dim cd As Single
    11.    
    12.     x1 = p1.X: y1 = p1.Y
    13.     x2 = p2.X: y2 = p2.Y
    14.     x3 = p3.X: y3 = p3.Y
    15.    
    16.     Temp = x2 * x2 + y2 * y2
    17.     bc = (x1 * x1 + y1 * y1 - Temp) / 2
    18.     cd = (Temp - x3 * x3 - y3 * y3) / 2
    19.     Det = 1 / ( (x1 - x2) * (y2 - y3) - (x2 - x3) * (y1 - y2) )
    20.    
    21.     GetCenter.X = (bc * (y2 - y3) - cd * (y1 - y2)) * Det
    22.     GetCenter.Y = ((x1 - x2) * cd - (x2 - x3) * bc) * Det
    23. End Function
    Last edited by Fox; Aug 11th, 2004 at 01:58 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width