title: What is the algorithm for finding the center of a circle from three points?
body: <p>I have three points on the circumference of a circle:</p>
  
  <pre><code>pt A = (A.x, A.y);
  pt B = (B.x, B.y);
  pt C = (C.x, C.y);
  </code></pre>
  
  <p>How do I calculate the center of the circle?</p>
  
  <p>Implementing it in Processing (Java).</p>
  
  <p>I found the answer and implemented a working solution:</p>
  
  <pre><code> pt circleCenter(pt A, pt B, pt C) {
  
      float yDelta_a = B.y - A.y;
      float xDelta_a = B.x - A.x;
      float yDelta_b = C.y - B.y;
      float xDelta_b = C.x - B.x;
      pt center = P(0,0);
  
      float aSlope = yDelta_a/xDelta_a;
      float bSlope = yDelta_b/xDelta_b;  
      center.x = (aSlope*bSlope*(A.y - C.y) + bSlope*(A.x + B.x)
          - aSlope*(B.x+C.x) )/(2* (bSlope-aSlope) );
      center.y = -1*(center.x - (A.x+B.x)/2)/aSlope +  (A.y+B.y)/2;
  
      return center;
    }
  </code></pre>