title: Find Arc/Circle equation given three points in space (3D)
body: <p>Given 3 points in space (3D): A = (x1, y1, z1), B = (x2, y2, z2) C = (x3, y3, z3); then how to find the center and radius of the circle (arc) that passes through these three points, i.e. find circle equation?  Using Python and Numpy here is my initial code  </p>
  
  <pre><code>import numpy as np
  A = np.array([x1, y1, z1])
  B = np.array([x2, y2, z2])
  C = np.array([x3, y3, z3])
  
  #Find vectors connecting the three points and the length of each vector
  AB = B - A 
  BC = C - B 
  AC = C - A 
  
  # Triangle Lengths
  a = np.linalg.norm(AB)
  b = np.linalg.norm(BC)
  c = np.linalg.norm(AC)
  </code></pre>
  
  <p>From the Circumradius definition, the radius can be found using:</p>
  
  <pre><code>R = (a * b * c) / np.sqrt(2.0 * a**2 * b**2 +
                            2.0 * b**2 * c**2 +
                            2.0 * c**2 * a**2 -
                            a**4 - b**4 - c**4)
  </code></pre>
  
  <p>However, I am having problems finding the Cartesian coordinates of the center.  One possible solution is to use the "Barycentric Coordinates" of the triangle points to find the  trilinear coordinates of the circumcenter (<a href="http://mathworld.wolfram.com/Circumcenter.html">Circumcenter</a>).  </p>
  
  <p>First (<a href="http://mathworld.wolfram.com/BarycentricCoordinates.html">using this source</a>) we find the circumcenter barcyntric coordinates:</p>
  
  <pre><code>#barcyntric coordinates of center
  b1 = a**2 * (b**2 + c**2 - a**2)
  b2 = b**2 * (c**2 + a**2 - b**2)
  b3 = c**2 * (a**2 + b**2 - c**2)
  </code></pre>
  
  <p>Then the Cartesian coordinates of the center (P) would be:</p>
  
  <pre><code>Px = (b1 * A[0]) + (b2 * B[0]) + (b3 * C[0])
  Py = (b1 * A[1]) + (b2 * B[1]) + (b3 * C[1])
  Pz = (b1 * A[2]) + (b2 * B[2]) + (b3 * C[2])   
  </code></pre>
  
  <p>However, the barcyntric coordinates values above do not seem to be correct. When solved with an example of known values, the radius is correct, but the coordinates of the center are not. </p>
  
  <p>Example:  For these three points:</p>
  
  <pre><code>A = np.array([2.0, 1.5, 0.0])
  B = np.array([6.0, 4.5, 0.0])
  C = np.array([11.75, 6.25, 0.0]) 
  </code></pre>
  
  <p>The radius and center coordinates are:</p>
  
  <pre><code>R = 15.899002930062595
  P = [13.4207317073, -9.56097560967, 0]
  </code></pre>
  
  <p>Any ideas on how to find the center coordinates? </p>