Calculate the coordinates of points on a circle in 3D space

4k Views Asked by At

Finding the $(x,y)$ coordinates of points along the circumference of a circle in 2D space is fairly easy.

x = r * cos() + Xc

y = r * sin() + Yc

r = radius of circle
(Xc, Yc) = coordinates of circle center
 = current angle

I am looking for similar equations for a circle in 3D space. Keep in mind I haven't had geometry in 20 years and we didn't cover 3D geometry. So please go easy on me and explain any notation you use.

3

There are 3 best solutions below

7
On BEST ANSWER

You could write the equations of the circle as

$$x = r \cos $$ $$y = r \sin $$ $$z=0$$

So, it is a special 3D circle with its z-coordinate always at zero. A true 3D circle can be produced from rotating the coordinates around any line $y=kx$.

For convenience, we rotate the coordinates around $y$-axis by an angle $\alpha$. From the standard coordinate transformation, we have

$$ x’ = x\cos\alpha - z\sin\alpha$$ $$ y’ = y$$ $$ z’= x\sin\alpha + z \cos\alpha $$

Plug the original coordinates of the circle above into the transformed coordinates, we get

$$ x’ = r\cos\theta \cos\alpha$$ $$ y’ = r\sin\theta$$ $$ z’= r\cos\theta\sin\alpha $$

which are the 3D coordinates of the original circle after the coordinates are rotated about the $y$-axis by an angle $\alpha$.

4
On

Think on the intersection between an sphere $x^2+y^2+z^2= r^2$ and a plane $a x + b y + c z = 0$

Solving for $x,y$ we get

$$ x = \frac{-a c z\mp\sqrt{b^2 \left(r^2 \left(a^2+b^2\right)-z^2 \left(a^2+b^2+c^2\right)\right)}}{a^2+b^2}\\ y = \frac{-b^2 c z\pm a \sqrt{b^2 \left(r^2 \left(a^2+b^2\right)-z^2 \left(a^2+b^2+c^2\right)\right)}}{b \left(a^2+b^2\right)} $$

now $z$ is such that $r^2 \left(a^2+b^2\right)-z^2 \left(a^2+b^2+c^2\right) \ge 0$ or

$$ -\frac{r\sqrt{a^2+b^2}}{\sqrt{a^2+b^2+c^2}}\le z \le \frac{r\sqrt{a^2+b^2}}{\sqrt{a^2+b^2+c^2}} $$

so finally we have a parametric representation

$$ x = x(z)\\ y = y(z)\\ $$

for

$$ -\frac{r\sqrt{a^2+b^2}}{\sqrt{a^2+b^2+c^2}}\le z \le \frac{r\sqrt{a^2+b^2}}{\sqrt{a^2+b^2+c^2}} $$

NOTE

we assumed $a,b,c$ all non null. The cases in which with one of them, or two are null, are trivial because the plane equation is simpler.

Attached the solution for $a=1,b=1,c=1,r=1$ and $-\sqrt{\frac 23}\le z\le \sqrt{\frac 23}$

enter image description here

3
On

Let’s rewrite your original parameterization a bit: $\vec c + (r\cos\theta) \vec e_1 + (r\sin\theta) \vec e_2$. Here $\vec e_1$ and $\vec e_2$ are the standard unit basis vectors. We can absorb $r$ into these vectors by setting $\vec u=r\vec e_1$ and $\vec v=\vec e_2$. Observe now that we can start anywhere on the circumference by making the substitution $\theta=\phi+\delta$ for some fixed angle $\delta$. This amounts to rotating $\vec u$ and $\vec v$ clockwise about the center $\vec c$ through an angle of $\delta$. We can also apply a reflection, which amounts to traversing the circle clockwise instead of counterclockwise. The upshot of all this is that we can choose any pair of perpendicular radii $\vec u$ and $\vec v$ for the parameterization $\vec c+\vec u\cos\theta+\vec v\sin\theta$. This works regardless of the dimension of the ambient space—you can always start with an appropriately-sized circle in the $x$-$y$ plane and map it to the desired circle with a rigid motion.

This generalizes to ellipses, but now the vectors $\vec u$ and $\vec v$ are conjugate half-diameters. You should be able to convince yourself of this by examining the effect of an affine transformation on the unit circle. A similar parameterization exists for hyperbolas, but it uses (unsurprisingly) the hyperbolic since and cosine.