The Torus and SupertoroidWritten by Paul BourkeMay 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.
where theta and phi range from 0 to 2pi. 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
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 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
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 TorusWritten by Paul BourkeDecember 2000
x = (c + cos(v)) cos(u)
The surface doesn't intersect itself for c > 1. c = 0.5
c = 1.0
c = 1.5
c = 2.5
Solid
Limpet TorusGraphics by Paul BourkeFebruary 2005 Attributed to Roger Bagula
x = cos(u) / [sqrt(2) + sin(v)]
Gumdrop torusGraphics by Paul BourkeMarch 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 TorusWritten by Paul BourkeDecember 2000
x = cos(u) (c + sin(v) cos(u)  sin(2 v) sin(u) / 2)
c = 1
c = 1.5
c = 0.5
2TorusBy Roger BagulaGraphics by Paul Bourke July 2007
x = cos(u) (2^{1/4} + cos(v))
Saddle torusBy Roger BagulaGraphics by Paul Bourke August 2002
x = [2 + cos(u)] cos(v)
Kinky TorusGraphics by Paul BourkeJune 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
