Information Technology
ENContact

Torus

Definition

Take a hollow cylinder (a tube), bend it to a ring, connect the two open ends and you get a torus:

Torus

Another construction is to revolve a circle in three dimensional space about an axis coplanar with the circle (Wikipedia). The torus is in a standard, canonical position if the circle is perpendicular to the x/y-plane and is rotated about the z-axis.

Implicit Equation

The implicit equation of the canonical torus with inner radius r and revolving radius R is:

(R -  x2 + y2 )2 + z2 = r2
(1)

This formula is derived in the figures below.

Torus

Torus

Parametric Equation

Torus is a 2-dimensional surface and hence can be parametrized by 2 independent variables which are obviously the 2 angles:

α = angle in the x/y-plane, around the z-axis, 0° ≤ α < 360°
(1a)
β = angle around the x/y-plane, 0° ≤ β < 360°
(1b)

Torus

The vector c from the origin O to the inner center C of the torus is:

c(α) = (R cosα, R sinα, 0)T
(2)

The vector d from the inner center C of the torus to the point A on the torus surface can be written as the sum of its orthogonal components:

d = cosβ c1 + sinβ z1
(3a)
c1 = (cosα, sinα, 0)T
(3b)
z1 = (0, 0, 1)T
(3b)

The vector a = (x, y, z)T from the origin to an arbitrary point A(x, y, z) on the torus surface is:

a = c + d 
(4)

By substituting (2) and (3) into (4) we get the parametric equations of the torus:

x(α, β) = (R + r cosβ) cosα  
(5a)
y(α, β) = (R + r cosβ) sinα  
(5b)
z(α, β) = r sinβ  
(5c)

The parameters α, β are usually denoted by u, v, respectively.

Octave Program

An Octave program (see also SourceForge) for drawing a torus is below (similar to Matlab):

function f = torus(r, R, numGridPoints)
    gridPoints = linspace(0, 2*pi, numGridPoints);
    [u, v] = meshgrid(gridPoints, gridPoints);
    x = (R + r * cos(v)) * cos(u);
    y = (R + r * cos(v)) * sin(u);
    z = r * sin(v);
    surf(x, y, z);
end