13
$\begingroup$

Given the three coordinates $(x_1, y_1, z_1)$, $(x_2, y_2, z_2)$, $(x_3, y_3, z_3)$ defining a circle in 3D space, how to find the coordinates of the center of the circle $(x_0, y_0, z_0)$?

$\endgroup$
1
  • $\begingroup$ @Behaviour I don't think this is an exact duplicate because the answers to the previous question only work in 2D. $\endgroup$
    – user856
    Dec 21, 2014 at 2:36

13 Answers 13

5
$\begingroup$

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.

$\endgroup$
4
  • $\begingroup$ Can you demonstrate how to convert from a 3D system to a 2D system? $\endgroup$
    – Dylan
    Dec 21, 2014 at 22:38
  • $\begingroup$ I added more details to my answer. Hope it helps. $\endgroup$
    – fang
    Dec 22, 2014 at 4:16
  • $\begingroup$ That's an interesting method. I still prefer my own method, which is exactly the same but without the change of coordinates. $\endgroup$
    – Dylan
    Dec 22, 2014 at 8:22
  • $\begingroup$ @Dylan: Your method creates bisecting planes. My method converst 3D coordinates to 2D coordinates and create bisecting lines. So, yes they are theoretically the same. But working in 2D is easier to visualize the picture for most people. $\endgroup$
    – fang
    Dec 22, 2014 at 18:24
5
$\begingroup$

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.

$\endgroup$
3
$\begingroup$

In fact, we have to solve the following system

$\cases{(x_0-x_1)^2+(y_0-y_1)^2+(z_0-z_1)^2=R^2\\ (x_0-x_2)^2+(y_0-y_2)^2+(z_0-z_2)^2=R^2\\ (x_0-x_3)^2+(y_0-y_3)^2+(z_0-z_3)^2=R^2\\ \left|\begin{array}{} x_0 & y_0 & z_0 & 1\\ x_1 & y_1 & z_1 & 1\\ x_2 & y_2 & z_2 & 1\\ x_3 & y_3 & z_3 & 1\\ \end{array}\right|=0}$

But I hope that somebody will write a nicer way.

Update. It seems the following.

Put $r_i=(x_i,y_i,z_i)$. Then the problem transformes to the following

$$\|r_1\|^2-2(r_0,r_1)= \|r_2\|^2-2(r_0,r_2)= \|r_3\|^2-2(r_0,r_3).$$

There exist real numbers $\mu_1, \mu_2, \mu_3$ such that $\mu_1+\mu_2+\mu_3=1$ and $r_0=\mu_1 r_1+\mu_2 r_2+\mu_3 r_3.$ We can find these numbers from a system of linear equations:

$$\mu_1+\mu_2+\mu_3=1$$

$$(1-2\mu_1) (r_1,r_1)-2\mu_2 (r_2,r_1)-2\mu_3 (r_3,r_1)=$$ $$-2\mu_1 (r_1,r_2)+(1-2\mu_2)(r_2,r_2)-2\mu_3 (r_2,r_3)=$$ $$-2\mu_1 (r_1,r_3)-2\mu_2(r_2,r_3)+(1-2\mu_3) (r_3,r_3).$$

$\endgroup$
7
  • $\begingroup$ The problem is you don't know R at this moment. $\endgroup$
    – fang
    Dec 21, 2014 at 20:54
  • $\begingroup$ @fang This is the smallest problem, :-) because we can easily eliminate $R$ and reduce the first three equations to two. $\endgroup$ Dec 21, 2014 at 20:59
  • $\begingroup$ That is true. But it is not immediately clear to non-math-savy developers.:-) $\endgroup$
    – fang
    Dec 21, 2014 at 21:13
  • $\begingroup$ @fang 4 equations in 4 unknowns - hard to be more clear. +1 $\endgroup$ Dec 21, 2014 at 21:27
  • $\begingroup$ Not so clear for nonlinear equations. At least to me. :-) $\endgroup$
    – fang
    Dec 21, 2014 at 21:30
3
$\begingroup$

I think this is one of the simplest solution:

Given three points of a circle:
$p1~(p1_x, p1_y, p1_z)^T$
$p2~(p2_x, p2_y, p2_z)^T$
$p3~(p3_x, p3_y, p3_z)^T$

Estimate the circle center:
$p0~(p0_x, p0_y, p0_z)^T$


  1. Estimate vectors $v1$ and $v2$:

$v1 = p2-p1 = (v1_x, v1_y, v1_z)^T $
$v2 = p3-p1 = (v2_x, v2_y, v2_z)^T $

  1. Estimate dot products:

$v11 = v1^T·v1$
$v22 = v2^T·v2$
$v12 = v1^T·v2$

  1. Estimate scalars $k_1$ and $k_2$:

$k_1 = b·v22·(v11 - v12)$

$k_2 = b·v11·(v22 - v12)$

$b = \frac{1}{2·(v11·v22-v12^2)}$

  1. Estimate circle center p0:

$p0 = p1 + k_1·v1 + k_2·v2$

==>

$p0_x = p1_x + k_1·v1_x + k_2·v2_x$
$p0_y = p1_y + k_1·v1_y + k_2·v2_y$
$p0_z = p1_z + k_1·v1_z + k_2·v2_z$

Full derivation and code here: https://github.com/sergarrido/random/tree/master/circle3d

$\endgroup$
2
$\begingroup$

Another possible way.

The equation of a sphere in 3D space can be written as: $$ x^2+y^2+z^2-2\alpha x -2\beta y -2\gamma z +d=0 $$ where $(\alpha,\beta,\gamma)$ are the coordinate of the center $O$ and $d=\alpha^2+\beta^2+\gamma^2-R^2$

Given three points $A=(x_A,y_A,z_A)$, $B=(x_B,y_B,z_B)$, $C=(x_C,y_C,z_C)$, substituting in this equation we find three linear equations in $\alpha$,$\beta$, $\gamma$ and $d$ that we can write in the form: $$ x_A\alpha+y_A\beta+z_A\gamma=\dfrac{d-|A|^2}{2} $$ $$ x_B\alpha+y_B\beta+z_B\gamma=\dfrac{d-|B|^2}{2} $$ $$ x_C\alpha+y_C\beta+z_C\gamma=\dfrac{d-|C|^2}{2} $$ where $|A|^2=x_A^2+y_A^2+z_A^2$, $|B|^2=x_B^2+y_B^2+z_B^2$ and $|C|^2=x_C^2+y_C^2+z_C^2$.

From these equations, we can find $\alpha$, $\beta$ and $\gamma$ as functions of $d$ and this corresponds to the fact that there are infinite spheres passing through the given points.

Now, the circle that we want is the maximum circle of the sphere that has the center on the plane that contain the three points and this menas that the three vectors $OA$,$OB$ and $OC$ are linearly dependent, so we must have:

$$ \det \begin{bmatrix} \alpha-x_A &\beta-y_A &\gamma-z_A\\ \alpha-x_B &\beta-y_B &\gamma-z_B\\ \alpha-x_C &\beta-y_C &\gamma-z_C\\ \end{bmatrix}=0 $$ with abit of calculus we can see that this reduces to: $$ \alpha \det \begin{bmatrix} 1 &y_A &z_A\\ 1 &y_B &z_B\\ 1 &y_C &z_C\\ \end{bmatrix}+ \beta \det \begin{bmatrix} x_A &1 &z_A\\ x_B &1 &z_B\\ x_C &1 &z_C\\ \end{bmatrix}+ \gamma \det \begin{bmatrix} x_A &y_A &1\\ x_B &y_B &1\\ x_C &y_C &1\\ \end{bmatrix}- \det \begin{bmatrix} x_A &y_A &z_A\\ x_B &y_B &z_B\\ x_C &y_C &z_C\\ \end{bmatrix}=0 $$

That is another linear equation from which we can find the coordinates of the center and the radius.

$\endgroup$
1
$\begingroup$

Let the known points be $A(x_1, y_1, z_1)$, $B(x_2, y_2, z_2)$ and $C(x_3, y_3, z_3)$. We want to find $I(x,y,z)$ so that $I$ is coplanar with $A,B,C$ and equidistant from $A,B,C$.

There is a geometric way to solve this. I assume you know how to find the equation of plane from a point and a normal vector? If not, look here.

Based on that, you can think of $I$ as the intersection of 3 planes:

  1. Since $IA = IB$, $I$ must lie on the perpendicular bisecting plane of line segment $AB$. This is a plane that passes the midpoint $M\left(\frac{x_1+x_2}{2},\frac{y_1+y_2}{2},\frac{z_1+z_2}{2}\right)$ of $AB$, and is perpendicular to $AB$ (its normal vector is $\overrightarrow{AB}$).

  2. Similar to plane 1 but with line segment $AC$ or $BC$ instead of $AB$

  3. Finally, $I$ must lie on the plane containing the points $A,B,C$. Its normal vector is $\overrightarrow{AB} \times \overrightarrow{AC}$.

Once you have the equations for the above planes, you end up with a linear system of equations, which should be easy to solve. The solution to the system is the coordinate of $I$.

$\endgroup$
0
$\begingroup$

Direct result for 3 points in 2-space, but no coordinates result in 3-space for the circle center.

Need to recognize polynomial buildup pattern given by Mathematica, but not yet conclusive.

It may be attempted as a special case in 4D-embedding?

enter image description here

$\endgroup$
0
$\begingroup$

In this formula the center $O$ of a circumscribed circle of $\triangle ABC$ is expressed as a convex combination of its vertices in terms of coordinates $A,B,C$ and corresponding side lengths $a,b,c$, suitable for both 2d and 3d:

\begin{align} O&= A\cdot \frac{a^2\,(b^2+c^2-a^2)}{((b+c)^2-a^2)(a^2-(b-c)^2)} \\ &+B\cdot \frac{b^2\,(a^2+c^2-b^2)}{((a+c)^2-b^2)(b^2-(a-c)^2)} \\ &+C\cdot \frac{c^2\,(b^2+a^2-c^2)}{((b+a)^2-c^2)(c^2-(b-a)^2)} . \end{align}

$\endgroup$
0
$\begingroup$

Let the three points in space are $P_1$, $P_2$ and $P_3$ and the center of the circle passing through them is $C$. Define the three vectors, $\vec{D}_{21}$, $\vec{D}_{31}$ and $\vec{U}$, see Fig.1. Schematic. The Cartesian components of these three vectors are,

$ D_{21x} = P_{2x}-P_{1x} \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\, (1) \\D_{21y} = P_{2y}-P_{1y} \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\,\, (2) \\D_{21z} = P_{2z}-P_{1z} \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\,\, (3) \\D_{31x} = P_{3x}-P_{1x} \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\, (4) \\D_{31y} = P_{3y}-P_{1y} \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\,\, (5) \\D_{31z} = P_{3z}-P_{1z} \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\,\, (6) \\U_{x} = C_{x}-P_{1x} \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\quad\,\, (7) \\U_{y} = C_{y}-P_{1y} \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\quad\,\,\, (8) \\U_{z} = C_{z}-P_{1z} \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\quad\,\,\, (9)$

Since $C$ is equidistant to $P_1$, $P_2$ and $P_3$, the foot of the perpendiculars dropped from $C$ to $\vec{D}_{21}$ and $\vec{D}_{31}$ vectors are actually at the midpoint of these vectors. Then the following two vector dot product identities are valid.

$ \vec{U}\cdot\vec{D}_{21} = \vert\vec{U}\vert \vert\vec{D}_{21}\vert \cos\theta = \cfrac{1}{2}\vert\vec{D}_{21}\vert^2 \qquad\qquad\qquad\qquad\qquad\,\,\, (10) \\\vec{U}\cdot\vec{D}_{31} = \vert\vec{U}\vert \vert\vec{D}_{31}\vert \cos\beta = \cfrac{1}{2}\vert\vec{D}_{31}\vert^2 \qquad\qquad\qquad\qquad\qquad\,\,\, (11)$

After Eqs. (10) and (11) are broken into their Cartesian components and the equations are worked out,

$ D_{21x}U_{x}+D_{21y}U_{y}+D_{21z}U_{z} = F_{2} \qquad\qquad\qquad\qquad\qquad\,\,\,\,\,\,\, (12) \\ D_{31x}U_{x}+D_{31y}U_{y}+D_{31z}U_{z} = F_{3} \qquad\qquad\qquad\qquad\qquad\,\,\,\,\,\,\, (13)$

where,

$ F_{2} = \cfrac{1}{2}(D_{21x}^2+D_{21y}^2+D_{21z}^2) \qquad\qquad\qquad\qquad\qquad\qquad\,\,\,\,\, (14) \\F_{3} = \cfrac{1}{2}(D_{31x}^2+D_{31y}^2+D_{31z}^2) \qquad\qquad\qquad\qquad\qquad\qquad\,\,\,\,\, (15)$

Since $C$ is on the same plane with $P_1$, $P_2$ and $P_3$, this condition requires the following vector identity.

$ \vec{U}\cdot(\vec{D}_{21}\times\vec{D}_{31}) = 0 \qquad\qquad\qquad\qquad\qquad\qquad\qquad\qquad\,\,\,\, (16)$

After Eq. (16) is broken into its Cartesian components, it results in the following determinant identity.

$ \begin{vmatrix}U_x&U_y&U_z\\D_{21x}&D_{21y}&D_{21z}\\D_{31x}&D_{31y}&D_{31z}\\ \end{vmatrix}=0 \qquad\qquad\qquad\qquad\qquad\qquad\qquad\,\,\, (17)$

Eq. (17) simplifies into,

$ M_{23yz}U_{x}+M_{23xz}U_{y}+M_{23xy}U_{z} = 0 \qquad\qquad\qquad\qquad\qquad (18)$

where,

$ M_{23xy} = D_{21x}D_{31y}-D_{21y}D_{31x} \qquad\qquad\qquad\qquad\qquad\qquad (19) \\M_{23yz} = D_{21y}D_{31z}-D_{21z}D_{31y} \qquad\qquad\qquad\qquad\qquad\qquad\, (20) \\M_{23xz} = D_{21z}D_{31x}-D_{21x}D_{31z} \qquad\qquad\qquad\qquad\qquad\qquad (21)$

In summary, Eqs. (12), (13) and (18) are the three linear equations needed in order to calculate the three coordinates of vector $\vec{U}$. They can be written in matrix form as follows.

$ \begin{bmatrix} M_{23yz}&M_{23xz}&M_{23xy}\\D_{21x}&D_{21y}&D_{21z}\\D_{31x}&D_{31y}&D_{31z}\\ \end{bmatrix} \begin{Bmatrix} U_{x}\\U_{y}\\U_{z}\\ \end{Bmatrix} = \begin{Bmatrix} 0\\F_{2}\\F_{3}\\ \end{Bmatrix} \qquad\qquad\quad\,\,\,\, (22)$

After solving Eq. (22) for $U_{x}$, $U_{y}$ and $U_{z}$ and back substituting to Eqs. (7), (8) and (9), the closed form solution of the coordinates of point $C$ are found as follows.

$ C_{x} = P_{1x} + \cfrac{M_{23xy}F_{23y}-M_{23xz}F_{23z}}{M_{23xy}^2+M_{23yz}^2+M_{23xz}^2} \qquad\qquad\qquad\qquad\,\,\,\,\,\,\,\, (23) \\C_{y} = P_{1y} + \cfrac{M_{23yz}F_{23z}-M_{23xy}F_{23x}}{M_{23xy}^2+M_{23yz}^2+M_{23xz}^2} \qquad\qquad\qquad\qquad\,\,\,\,\,\,\,\, (24) \\C_{z} = P_{1z} + \cfrac{M_{23xz}F_{23x}-M_{23yz}F_{23y}}{M_{23xy}^2+M_{23yz}^2+M_{23xz}^2} \qquad\qquad\qquad\qquad\,\,\,\,\,\,\,\, (25)$

where,

$ F_{23x} = F_{2}D_{31x}-F_{3}D_{21x} \qquad\qquad\qquad\qquad\qquad\qquad\qquad (26) \\F_{23y} = F_{2}D_{31y}-F_{3}D_{21y} \qquad\qquad\qquad\qquad\qquad\qquad\qquad\, (27) \\F_{23z} = F_{2}D_{31z}-F_{3}D_{21z} \qquad\qquad\qquad\qquad\qquad\qquad\qquad\, (28)$

For coding purposes, find the full set of equations in text form below.

D21x = P2x-P1x
D21y = P2y-P1y
D21z = P2z-P1z
D31x = P3x-P1x
D31y = P3y-P1y
D31z = P3z-P1z

F2 = 1/2*(D21x^2+D21y^2+D21z^2)
F3 = 1/2*(D31x^2+D31y^2+D31z^2)

M23xy = D21x*D31y-D21y*D31x
M23yz = D21y*D31z-D21z*D31y
M23xz = D21z*D31x-D21x*D31z

F23x = F2*D31x-F3*D21x
F23y = F2*D31y-F3*D21y
F23z = F2*D31z-F3*D21z

Cx = P1x+(M23xy*F23y-M23xz*F23z)/(M23xy^2+M23yz^2+M23xz^2)
Cy = P1y+(M23yz*F23z-M23xy*F23x)/(M23xy^2+M23yz^2+M23xz^2)
Cz = P1z+(M23xz*F23x-M23yz*F23y)/(M23xy^2+M23yz^2+M23xz^2)
$\endgroup$
3
  • $\begingroup$ You may want to consult math.meta.stackexchange.com/questions/5020/… $\endgroup$ Jan 12, 2020 at 4:36
  • $\begingroup$ Equations reformatted based on @Calvin Khor 's advice. $\endgroup$ Jan 12, 2020 at 17:00
  • $\begingroup$ Equations and the formula derivation updated. At the previous version, $C_y$ and $C_z$ equations had division by $M_{23yz}$. They used to yield calculation errors when $M_{23yz} = 0$. This corresponds to the case when $P_1 P_2 P_3$ plane passes through $x$ axis. Current formulation has eliminated this problem. $\endgroup$ May 29, 2021 at 19:40
0
$\begingroup$

Numerically attempted a solution. Computed the circle center, which is also circum-center of the triangle formed by joining the three assumed points.. in the program below. The sides are found, the circumradius R is calculated using trigonometric relations.

R is then equated to each of the three center to vertex distances to get the circle center, conventional way by solving three equations for the center.

Did not have luck so far finding the center coordinates analytically. Any help for generalizing the above in Mathematica or in other ways would be much appreciated.

x1=3;y1=5.;z1=3.2;x2=3;y2=5;z2=.8;x3=1.2;y3=.7;z3=5.2;a=Sqrt[(x1-x2)^2+(y1-y2)^2+(z1-z2)^2];b=Sqrt[(x2-x3)^2+(y2-y3)^2+(z2-z3)^2];c=Sqrt[(x3-x1)^2+(y3-y1)^2+(z3-z1)^2];s=(a+b+c)/2;Area=Sqrt[s(s-a)(s-b)(s-c)];R=a b c/4/Area;eq={(xc-x1)^2+(yc-y1)^2+(zc-z1)^2==R^2,(xc-x2)^2+(yc-y2)^2+(zc-z2)^2==R^2,(xc-x3)^2+(yc-y3)^2+(zc-z3)^2==R^2};NSolve[eq,{xc,yc,zc}]
                                                                                                                                                                                                                                                                                                                                  
Out[41]= {{xc->1.73553,yc->1.97931,zc->2.},{xc->1.73553,yc->1.97931,zc->2.}}
$\endgroup$
0
$\begingroup$

The circle in 3D space is an intersection of a sphere and a plane. Therefore, consider the sphere passing through the three given points and an extra point $p$ of your choosing, and consider the plane given by your three points $P=v_1\xi_1+v_2\xi_2+v_3(1-\xi_1-\xi_2)$. The sphere has the equation $$\begin{vmatrix}x^2+y^2+z^2,& x,&y,&z,&1\\ x^2_1+y^2_1+z^2_1,& x_1,&y_1,&z_1,&1\\ x^2_2+y^2_2+z^2_2,&x_2,&y_2,&z_2,&1\\ x^2_3+y^2_3+z^2_3,&x_3,&y_3,&z_3,&1\\ p^2_x+p^2_y+p^2_z,&p_x,&p_y,&p_z,&1\\\end{vmatrix}=0.$$ Now substitute $$x=x_1\xi_1+x_2\xi_2+x_3(1-\xi_1-\xi_2)\\\vdots \\ z=z_1\xi_1+z_2\xi_2+z_3(1-\xi_1-\xi_2),$$ which gives the equation of the circle in the $\xi_1\xi_2$ plane. Now the center can be extracted from the coefficients, which gives $\xi_1$ and $\xi_2$ values.

$\endgroup$
-1
$\begingroup$

Let's assume the circle is defined by the 3 points a, b and c, and that the center is denoted d. Following the hints in the answers above the coordinates of points a, b and c can be plugged into the equation of a circle. 3 circle equations and 4 unknowns (3 coordinates of the center c plus the radius) means that we have 2 remaining unknowns for one equation. This equation in fact represents the line passing through the center of the circle, having equal distance to points a, b and c. Intersecting this line with the plane spanned by a, b and c gives the point c. The rest is algebra, making use of some smart substitution of variables:

        Cx = bx-ax
        Cy = by-ay
        Cz = bz-az
        Bx = cx-ax
        By = cy-ay
        Bz = cz-az
        B2 = ax**2-cx**2+ay**2-cy**2+az**2-cz**2
        C2 = ax**2-bx**2+ay**2-by**2+az**2-bz**2

        CByz = Cy*Bz-Cz*By
        CBxz = Cx*Bz-Cz*Bx
        CBxy = Cx*By-Cy*Bx
        ZZ1 = -(Bz-Cz*Bx/Cx)/(By-Cy*Bx/Cx)
        Z01 = -(B2-Bx/Cx*C2)/(2*(By-Cy*Bx/Cx))
        ZZ2 = -(ZZ1*Cy+Cz)/Cx
        Z02 = -(2*Z01*Cy+C2)/(2*Cx)

and finally the coordinates of the center:

        dz = -((Z02-ax)*CByz-(Z01-ay)*CBxz-az*CBxy)/(ZZ2*CByz-ZZ1*CBxz+CBxy)
        dx = ZZ2*dz + Z02
        dy = ZZ1*dz + Z01
$\endgroup$
2
  • 2
    $\begingroup$ Perhaps a little explanation of your logic would be helpful to the asker? $\endgroup$
    – The Count
    Nov 11, 2016 at 15:50
  • $\begingroup$ An explanation would still be nice, even a year and a half later. People are still finding this post when looking for how to fit a circle through three points in 3D =) $\endgroup$ Jul 7, 2018 at 17:41
-1
$\begingroup$

I know this is late but hopefully this can help someone else. I will write it down in steps without explaining too much as I believe the steps are simple enough. Let the points be P1 P2 and P3.

  1. Calculate the plane containing the three points.
  2. Calculate the perpendicular bisectors of the line segments [P1 P2] and [P1 P3] , or any other combination that you want, such that this perpendicular bisector also lies in the plane containing P1,P2 and P3.
  3. The intersection of these 2 perpendicular bisectors should be the center of the cricle.

I can elaborate more if anyone wishes so :-)

$\endgroup$
1
  • $\begingroup$ this answer just describes, in far less detail, the exact answer @fang already gave in 2014 $\endgroup$ Jul 7, 2018 at 17:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .