The Torus and Supertoroid

Written by Paul Bourke
May 1990

The torus is perhaps the least used object in real modelling applications but it still appears as a standard form in modelling and rendering packages ahead of far more useful geometric primitives. In any case, given the conventions below, that is, defining the radius (r0) from the center to the middle of the ring of the torus and the radius (r1) of the cross section of ring of the torus.

The points on the torus are defined as

x = cos(theta) * [ r0 + r1 * cos(phi) ]
y = sin(theta) * [ r0 + r1 * cos(phi) ]
z = r1 * sin(phi)

Or in an implicit form

z2 + (sqrt(x2 + y2) - a)2 - b2 = 0

where theta and phi range from 0 to 2pi. Using the above formulation a torus with center radius r0 = 1 and outer radius r1 = 0.25 will look something like this

The code for generating a facet approximation to a torus as described later involves creating facets with vertices defined by

theta + dtheta,phi
theta + dtheta,phi + dphi
theta,phi + dphi

If a facet approximation to a torus is required then a large number of facets are generally necessary to produce a smooth rendered surface. In the wire frame example above dphi and dtheta were 10degrees, this results in 36x36=1296 facets.

Another approach is to create a torus from a number of spheres which rendering packages often support more efficiently. This is achieved by simply packing spheres around a circular path, radius r0. The radius of the sphere being the radius r1. For example, the following shows the same torus dimension as in the earlier example created with 50 and 100 spheres.

C Source

This C code generated the facet representation shown above, the planar facets are exported in DXF for this example.

Supertoroid - A Geometric Primitive for Computer Aided Design

The supertoroid is a family of geometric primitives based on the torus. Let
r0 the radius of the inner ring
r1 the radius of the outer ring
as illustrated below where theta and phi range from 0 to 2pi.

The equation for the supertoroid is the same as that for the torus except that the sin and cosine terms are raised to powers.

It is different values of these powers which give rise to a family of 3D shapes all basically toroidal in shape. The value of n1 determines the shape of the torus ring, n2 determines the shape of the cross section of the ring. Note that with the normal definition of power the above equations are only defined for a single quadrant, namely that where the cosine and sine terms are positive. When creating the supertorus in practice one has two choices, either replicate the result in the one quadrant to the other three with the correct mirror operations, or define xn = sign(x) * abs(x)n.

Examples of the supertoroid generated for different values of n1 and n2 are shown below, of course, the legal values of n1 and n2 form a continuum of values from 0 to infinity (although there are representation issues near 0 and above 4).

An idea of the continuum of cross sectional shapes offered by squaring the sin() and cosine() terms consider the following

C source

Code which generates a facet based supertoroid in DXF format is given here. (Written for clarity not efficiency). Something similar for stl is here.

Elliptic Torus

Written by Paul Bourke
December 2000

x = (c + cos(v)) cos(u)
y = (c + cos(v)) sin(u)
z = sin(v) + cos(v)
-pi <= u,v <= pi

The surface doesn't intersect itself for c > 1.

c = 0.5

c = 1.0

c = 1.5

c = 2.5

Physical version created using the ZCorp Z406 colour rapid prototyping machine.

Limpet Torus

Graphics by Paul Bourke
February 2005

Attributed to Roger Bagula

x = cos(u) / [sqrt(2) + sin(v)]
y = sin(u) / [sqrt(2) + sin(v)]
z = 1 / [sqrt(2) + cos(v)]

Gumdrop torus

Graphics by Paul Bourke
March 2003

4 [x4 + (y2 + z2)2] + 17 x2 (y2 + z2) - 20 (x2 + y2 + z2) + 17 = 0

PovRay scene: gumdrop.pov

Figure 8 Torus

Written by Paul Bourke
December 2000

x = cos(u) (c + sin(v) cos(u) - sin(2 v) sin(u) / 2)
y = sin(u) (c + sin(v) cos(u) - sin(2 v) sin(u) / 2)
z = sin(u) sin(v) + cos(u) sin(2 v) / 2
-pi <= u,v <= pi

c = 1

c = 1.5

c = 0.5


By Roger Bagula
Graphics by Paul Bourke
July 2007

x = cos(u) (21/4 + cos(v))
y = sin(u) (21/4 + sin(v))
z = sqrt((u/pi)2 + (v/pi)2)

Saddle torus

By Roger Bagula
Graphics by Paul Bourke
August 2002

x = [2 + cos(u)] cos(v)
y = [2 + cos(u + 2 pi / 3)] cos(v + 2 pi / 3)
z = [2 + sign(F(u)) sqrt(|F(u)|)] sign(F(v)) sqrt(|F(v)|)
where F(s) = 1 - cos(s)2 - cos(s + 2 pi / 3)2
0 <= u <= 2 pi, 0 <= v <= 2 pi

Kinky Torus

Graphics by Paul Bourke
June 2003

Equations by Roger Bagula

x = sech(u) - cos(v)

y = sin(v)

z = u / PI - tanh(u)

-2 pi <= u <= 2 pi, -pi < v < pi