General equation of a translated and rotated torus

3danalytic geometryrotationssurfaces

every source I've found about Tori describe the Torus equation as:

$$\left(\sqrt{x^2 + y^2} -R\right)^2 + z^2 = r^2$$

where:

  • $R$ is the distance between the center of the hole and the center of the tube;
  • $r$ is the radius of the tube.

By this answer I can realize that this equation assumes that the origin of the $xyz$ system is the center of the hole.

Thus, what is the equation for a torus which is not in the origin? And how to derive the torus equation for a rotated torus like the ones in the following image?

3 tori rotated and translated fro the origin

EDIT: I would appreciate if someone with enough reputation can create a "torus" tag and tag this question with it.

Best Answer

Almost a year late but hopefully this helps someone. This answer is based on my own experiences in creating software that generates rotated and translated tori. This isn't specific to tori - for any shape you can rotate and then translate the point before applying the equation.

Translational:

$$(\sqrt{(x-a)^2 + (y-b)^2} - R)^2 + (z-c)^2 \leq r^2$$

where

  • $R$ is the major radius, or 'the distance between the center of the hole and the center of the tube'.
  • $r$ is the minor radius, or 'the radius of the tube'.
  • $[a,b,c]$ is the center of the torus

Rotational:

For each $x,y,z \in \mathbb{R}$ we can map $[x,y,z]^T \to H \cdot [x,y,z]^T $, where $H$ is a rotation matrix.

To make this an equation you could split the rotation matrix up. Lets say $H_0$ is the first row, $H_1$ the second, and $H_2$ the third. Let $p$ be $[x,y,z]^T$.

$$(\sqrt{(H_0 \cdot p)^2 + (H_1 \cdot p)^2} - R)^2 + (H_2 \cdot p)^2 \leq r^2$$

Translational and Rotational:

You'll need to apply the rotation first, then translate. This is because the rotation matrix will rotate about the origin. If you translate it first, the rotation will not be around the center of the torus.

The full equation would be

$$(\sqrt{((H_0 \cdot p) - a)^2 + ((H_1 \cdot p) - b)^2} - R)^2 + ((H_2 \cdot p) - c)^2 \leq r^2$$

where

  • $R$ is the major radius, or 'the distance between the center of the hole and the center of the tube'.
  • $r$ is the minor radius, or 'the radius of the tube'.
  • $p = [a,b,c]$ is the center of the torus
  • $H$ is the rotation matrix that rotates your torus
    • $H_0$ is the first row of $R$
    • $H_1$ is the second row of $R$
    • $H_2$ is the third row of $R$
Related Question