3D coordinates of circle center given three point on the circle.

Solution 1:

There are plenty of online articles for the 2D case. A simple google search will show that this link provides a good explanation about how this is done in 2D. It also shows how to construct the circle center geometrically. So, what you need to do is

1) Find a plane from the 3 points and create a 2D coordinate system on that plane.
2) Convert all 3 points to that 2D coordinate system.
3) Find the circle center using the link above.
4) Convert the circle center (in 2D) back to 3D.

Edit 1: I added the steps for creating a local coordinate system (CS) on a plane defined by 3 points

1) Compute unit vector n1 from P1 and P2. Use this as the x-axis for the local CS.
2) Compute unit vector n2 from P1 and P3.
3) Use n1 x n2 (where 'x' means the cross product) as the z-axis of the local CS.
4) Use (n1 x n2) x n1 as the y-axis of the local CS.
5) Now, you have a local coordinate system, I hope that you know how to convert P1, P2 and P3 to this local CS. After the conversion, the new coordinates for these 3 points should all have their z values = 0.0. You can then use their (x, y) values to find the center of the circle.

If you have all 3 points collinear, you cannot create a local CS and you cannot find a circle from 3 collinear points either.

Solution 2:

I think using a projection into 2D might be the easiest way to actually calculate. If the points are $A, B, C$ then find

$$\begin{align} \mathbf{u_1} & = B-A \\ \mathbf{w_1} &= (C-A) \times \mathbf{u_1} \\ \mathbf{u} & = \mathbf{u_1} / | \mathbf{u_1} | \\ \mathbf{w} & = \mathbf{w_1} / | \mathbf{w_1} | \\ \mathbf{v} & = \mathbf{w} \times \mathbf{u} \\ \end{align}$$

This gives three orthogonal unit vectors with $\mathbf{u}$ and $\mathbf{v}$ spanning the plane.

Get 2D coordinated by taking the dot products of $(B-A)$ and $(C-A)$ with $\mathbf{u}$ and $\mathbf{v}$. Let

$$\begin{align} b & = (b_x,0) = ( (B-A) \cdot \mathbf{u} , 0 ) \\ c &= (c_x,c_y) = ( (C-A) \cdot \mathbf{u}, (C-A)\cdot \mathbf{v} ) \\ \end{align}$$

We know the center must lie on the line $x= b_x/2$. Let this point be $(b_x/2,h)$. The distance from c must be the same as the distance from the origin $$(c_x-b_x/2)^2 + (c_y - h)^2 = (b_x/2)^2 + h^2$$ So $$h = \frac{(c_x-b_x/2)^2 + c_y^2 - (b_x/2)^2}{ 2 c_y } $$

The actual center can then be recovered by taking $A + (b_x/2)\mathbf{u} + h \mathbf{v}$.

This is a nice explicit calculation.