The Torus and Supertorus
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 (r_{0})
from the center
to the middle of the
ring of the torus and the radius (r_{1}) of the cross section of
ring of the torus.

The points on the torus are defined as
x = cos(theta) * [ r_{0} + r_{1} * cos(phi) ]
y = sin(theta) * [ r_{0} + r_{1} * cos(phi) ]
z = r_{1} * sin(phi)
Or in an implicit form
z^{2} +
(sqrt(x^{2} + y^{2})  a)^{2}  b^{2} = 0

where theta and phi range from 0 to 2π. Using the above formulation
a torus with center radius r_{0} = 1
and outer radius r_{1} = 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,phi
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
10 degrees, 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 r_{0}.
The radius of the sphere being the radius r_{1}. 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 2π.
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 x^{n} = 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)
π <= u,v <= π

The surface doesn't intersect itself for c > 1.
c = 0.5
c = 1.0
c = 1.5
c = 2.5
Solid
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 [x^{4} + (y^{2} + z^{2})^{2}] +
17 x^{2} (y^{2} + z^{2}) 
20 (x^{2} + y^{2} + z^{2}) + 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
π <= u,v <= π

c = 1
c = 1.5
c = 0.5
2Torus
By Roger Bagula
Graphics by Paul Bourke
July 2007

x = cos(u) (2^{1/4} + cos(v))
y = sin(u) (2^{1/4} + sin(v))
z = sqrt((u/π)^{2} + (v/π)^{2})

Saddle torus
By Roger Bagula
Graphics by Paul Bourke
August 2002

x = [2 + cos(u)] cos(v)
y = [2 + cos(u + 2 π / 3)] cos(v + 2 π / 3)
z = [2 + sign(F(u)) sqrt(F(u))] sign(F(v)) sqrt(F(v))
where F(s) = 1  cos^{2}(s)  cos^{2}(s + 2 π / 3)
0 <= u <= 2 π, 0 <= v <= 2 π

Kinky Torus
Graphics by Paul Bourke
June 2003
Equations by Roger Bagula

x = sech(u)  cos(v)
y = sin(v)
z = u / π  tanh(u)
2 π <= u <= 2 π, π < v < π

Klein Bottle
Written by Paul Bourke
October 1996
A German topologist named Klein
Thought the Möbius Loop was divine
Said he, "If you glue
The edges of two
You get a weird bottle like mine."
Most containers have an inside and an outside,
a Klein bottle is a closed surface with no interior
and only one surface. It is unrealisable in 3 dimensions
without intersecting surfaces. It can be realised in 4
dimensions. The classical representation is shown below.



Featured in "mama 27", November 2000, pp 91, Figure 18.



The parametric equations to produce the above are:
A Klein bottle can be formed by taking two Möbius strips
and join them along their boundaries, this so called
"Figure8 Klein Bottle" can be parameterized as follows:
x = cos(u) (a + sin(v) cos(u/2)  sin(2v) sin(u/2)/2)
y = sin(u) (a + sin(v) cos(u/2)  sin(2v) sin(u/2)/2)
z = sin(u/2) sin(v) + cos(u/2) sin(2v)/2
where
π <= u <= π
and
π <= v <= π
Source code
This source code creates geometry files
in the "geom" format. For a description of this file format see the
specifications in the 3D file formats
section. You may choose to translate the resulting geom file into your
favourite file format or modify the code to create the format of your
choice, all you need to do is modify the bit where the polygon is
written to a file. This source code creates
the classical Klein bottle shape as described at the top of this
document.
If you are used to using GeomView then
this code creates a CMESH
that can be opened directly in that package. Alternatively if you have
a package that allows plotting of regular meshes then this is the code
to grab and modify.
If you would like to create a Klein bottle for a CAD package, this
source code creates a DXF file of the classical
Klein bottle. Alternatively, here is a sample DXF file
created using the above program and tessellating the bottle by a 50x50 mesh.
Tessel version
Gray's Klein bottle
Inspired by Roger Bagula, Graphics by Paul Bourke
September 2012
p.x = (a + cos(n*u/2.0) * sin(v)  sin(n*u/2.0) * sin(2*v)) * cos(m*u/2.0)
p.y = (a + cos(n*u/2.0) * sin(v)  sin(n*u/2.0) * sin(2*v)) * sin(m*u/2.0)
p.z = sin(n*u/2.0) * sin(v) + cos(n*u/2.0) * sin(2*v)
0 <= u <= 4 π
0 <= u <= 2 π

a = 2, n = 2, m = 1
a = 1.5, n = 2, m = 1
a = 3.0, n = 2, m = 1
a = 3.0, n = 3, m = 1
a = 2.5, n = 2, m = 2
a = 2.5, n = 3, m = 3
a = 2, n = 2, m = 1
a = 2, n = 2, m = 1
Möbius (Möbius) strip
Written by Paul Bourke
May 1996
The Möbius strip is the simplest geometric shape which has only one surface
and only one edge. It can be created by taking a strip of paper, giving it a half
twist along its long axis, and then joining the two narrow ends together.
The Möbius strip in 3 dimensions can be represented parametrically f(s,t)
as follows
where s ranges from 0 to 2*π and t ranges typically from 0.4 to 0.4
An example of such a strip is shown below.
Featured in "mama 27", November 2000, pp 91, Figure 17.
The band for different values of t are illustrated below.
t = 1 > 1
t = 0.1 > 0.1
t = 0.5 > 0.5
Increasing the range of t even further yields interesting folded
and increasingly convoluted forms.
Bow Tie
Graphics by Paul Bourke
February 2005
Attributed to Roger Bagula

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

Triaxial Tritorus
Supplied by Roger Bagula
Further discussion by Roger Bagula
Mathematica code by Roger Bagula.
Graphics by Paul Bourke
September 1998
C Code by Paul Bourke.
The Triaxial Tritorus is defined parametrically as
x = sin(u) (1 + cos(v))
y = sin(u + 2 / 3)
(1 + cos(v + 2 / 3))
z = sin(u + 4 / 3)
(1 + cos(v + 4 / 3))
Where
 <= u
<= and
 <= v
<=


Appeared on stickers for the MAA
(Mathematical Association of America).

Bohemian Dome
Graphics by Paul Bourke
February 2003

x = a cos(u)
y = a sin(u) + b cos(v)
z = c sin(v)
0 <= u <= 2 π, 0 <= v <= 2 π

Surface obtained by moving a circle that remains parallel to
a plane along a curve that is perpendicular to the same plane.
Triaxial Hexatorus
Graphics by Paul Bourke
February 2005
Attributed to Roger Bagula

x = sin(u) / [sqrt(2) + cos(v)]
y = sin(u+2π/3) / [sqrt(2) + cos(v+2π/3)]
z = cos(u2π/3) / [sqrt(2) + cos(v2π/3)]

Twisted Pipe Surface
By Roger Bagula
Graphics by Paul Bourke
August 2002

x = cos(v) * (2 + cos(u)) / sqrt(1 + sin(v)^{2})
y = sin(v + 2π/3) * (2 + cos(u + 2π/3)) / sqrt(1 + sin(v)^{2})
z = sin(v  2π/3) * (2 + cos(u  2π/3)) / sqrt(1 + sin(v)^{2})
0 <= u <= 2 π, 0 <= v <= 2 π

Double torus
Graphics by Paul Bourke
April 2004

z^{2} =
0.04  x^{4} + 2 x^{6} 
x^{8} + 2 x^{2} y^{2} 
2 x^{4} y^{2}  y^{4}
Credited to H. Karcher
PovRay scene:
doubletorus.pov

Bow Curve
By Paul Bourke
August 2002

x = (2 + T sin(2 pi u)) sin(4 pi v)
y = (2 + T sin(2 pi u)) cos(4 pi v)
z = T cos(2 pi u) + 3 cos(2 pi v)
0 <= u <= 1, 0 <= v <= 1, 0 < T (Thickness)

Pretzel
Graphics by Paul Bourke
November 2004
[ ((x1)^{2} + y^{2}  c^{2})
((x+1)^{2} + y^{2}  c^{2}) ]^{2} + z^{2} = d
Bretzel
Graphics by Paul Bourke
November 2004
(x^{2} (1x^{2})  y^{2})^{2} + z^{2} = 0.01
Pisot Triaxial
By Roger Bagula
Graphics by Paul Bourke
August 2002

x = 0.655866 cos(1.03002 + u) (2 + cos(v))
y = 0.754878 cos(1.40772  u) (2 + 0.868837 cos(2.43773 + v))
z = 0.868837 cos(2.43773 + u) (2 + 0.495098 cos(0.377696  v))
0 <= u <= 2 π, 0 <= v <= 2 π




