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

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

(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.

• Reworked the answer based on correct understanding Sep 28 '19 at 0:04

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$$.

• I assume I would also have to add the coordinates of the circle's center to those equations? Sep 27 '19 at 21:33
• Also, how would I find ๐? Assuming the circle isn't moving dose ๐ change at all? Sep 27 '19 at 21:39
• @iHorse - correct, you need to add the center coordinates as you do in 2D Sep 27 '19 at 21:53
• @Quanto On your diagram, the angles $\theta$ and $\phi$ are interchanged.
– A.Γ.
Sep 27 '19 at 22:01
• @Quanto I think you might have misunderstood what I was asking. If a plane where to intersect that sphere the result would be a 2D circle. The points on the circumference of that circle are what I am looking for. Sep 27 '19 at 22:17

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}$$

• How would I use those equations to find all the points along the circumference of the resulting circle? Sep 27 '19 at 21:54
• Attached the case $a=1,b=1,c=1,r=1$ with $-\sqrt{\frac 23}\le z\le \sqrt{\frac 23}$. Choosing $z$'s into this range we can draw the two foils for $(x(z),y(z),z)$ Sep 28 '19 at 10:46
• ok. If I understand correctly I would just increment z from the low end of that range to the upper end and plug the values into the first two equations along with the other relevant variables to get the points along the circumference of the circle. Sep 30 '19 at 15:50
• @iHorse Yes. Choosing $z$ values in the range, we can compute the corresponding $x(z),y(z)$. The vector $(a,b,c)$ represents the normal to the plane containing the circle with radius $r$ centered at $(0,0,0)$. Sep 30 '19 at 17:41

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.

• I was able to follow most of that. I don't quite see where you are getting the vectors e1 and e2. I know what a unit vector is I just don't know what you mean by "standard unit basis vectors". I assume that ๐ฟ would be the angle of the vector from the center of the sphere to the center of the circle relative to the x-y plane and by incrementing ๐ I am effectively walking around the circumference of the circle. Sep 30 '19 at 15:38
• @iHorse These are just the standard basis vectors $(1,0)$ and $(0,1)$. I.e., $(r\cos\theta+x_c,r\sin\theta+y_c)=(x_c,y_c)+r(\cos\theta,\sin\theta)=(x_c,y_c)+r\cos\theta(1,0)+r\sin\theta(0,1)=\vec c+(r\cos\theta)\vec e_1+(r\sin\theta)\vec e_2$.
– amd
Sep 30 '19 at 18:23
• @iHorse What sphere? Iโm working entirely in $\mathbb R^2$ in that first paragraph. The point of the substitution is that any point on the circle can be the โzero pointโ of the parameterization: use that radius as one of the two vectors. In this case the offset $\delta$ does directly represent an angle (the angle from the positive $x$-axis), but thatโs only because the parameters $\theta$ also directly corresponds to an angle. Donโt get locked into that, though. We could just as well parameterize the unit circle as, say, $(\cos3t,\sin3t)$, where $t$ doesnโt represent an angle.
– amd
Sep 30 '19 at 18:30