# Supertoroid

In geometry and computer graphics, a supertoroid or supertorus is usually understood to be a family of doughnut-like surfaces (technically, a topological torus) whose shape is defined by mathematical formulas similar to those that define the superquadrics. The plural of "supertorus" is either supertori or supertoruses.

The family was described and named by Alan Barr in 1994.

Barr's supertoroids have been fairly popular in computer graphics as a convenient model for many objects, such as smooth frames for rectangular things. One quarter of a supertoroid can provide a smooth and seamless 90-degree joint between two superquadric cylinders. However, they are not algebraic surfaces (except in special cases).

## Formulas

Alan Barr's supertoroids are defined by parametric equations similar to the trigonometric equations of the torus, except that the sine and cosine terms are raised to arbitrary powers. Namely, the generic point P(u, v) of the surface is given by

$P(u,v)=\left({\begin{array}{c}X(u,v)\\Y(u,v)\\Z(u,v)\end{array}}\right)=\left({\begin{array}{c}(a+C_{u}^{s})C_{v}^{t}\\(b+C_{u}^{s})S_{v}^{t}\\S_{u}^{s}\end{array}}\right)$ where $C_{\theta }^{\epsilon }=\operatorname {sgn} (\cos \theta )\left|\cos \theta \right|^{\epsilon }$ , $S_{\theta }^{\epsilon }=\operatorname {sgn} (\sin \theta )\left|\sin \theta \right|^{\epsilon }$ , and the parameters u and v range from 0 to 360 degrees (0 to 2π radians).

In these formulas, the parameter s > 0 controls the "squareness" of the vertical sections, t > 0 controls the squareness of the horizontal sections, and a, b ≥ 1 are the major radii in the X and Y directions. With s=t=1 and a=b=R one obtains the ordinary torus with major radius R and minor radius 1, with the center at the origin and rotational symmetry about the Z axis.

In general, the supertorus defined as above spans the intervals $[-(a+1),+(a+1)]$ in X, $[-(b+1),+(b+1)]$ in Y, and $[-1,+1]$ in Z. The whole shape is symmetric about the planes X=0, Y=0, and Z=0. The hole runs in the Z direction and spans the intervals $[-(a-1),+(a-1)]$ in X and $[-(b-1),+(b-1)]$ in Y.

A curve of constant u on this surface is an horizontal Lamé curve with exponent 2/t, scaled in X and Y and displaced in Z. A curve of constant v, projected on the plane X=0 or Y=0, is a Lamé curve with exponent 2/s, scaled and horizontally shifted. If v is 0, the curve is planar and spans the interval $[a-1,a+1]$ in X, and $[-1,+1]$ in Z; and similarly if v is 90, 180, or 270 degrees. The curve is planar also if a = b.

In general, if ab and v is not a multiple of 90 degrees, the curve of constant v will not be planar; and, conversely, a vertical plane section of the supertorus will not be a Lamé curve.

The basic supertoroid shape defined above is often modified by non-uniform scaling to yield supertoroids of specific width, length, and vertical thickness.

## Plotting code

The following GNU Octave code generates plots of a supertorus:

 function supertoroid(epsilon,a)
n=50;
d=.1;
etamax=pi;
etamin=-pi;
wmax=pi;
wmin=-pi;
deta=(etamax-etamin)/n;
dw=(wmax-wmin)/n;
k=0;
l=0;
for i=1:n+1
eta(i)=etamin+(i-1)*deta;
for j=1:n+1
w(j)=wmin+(j-1)*dw;
x(i,j)=a(1)*(a(4)+sign(cos(eta(i)))*abs(cos(eta(i)))^epsilon(1))*sign(cos(w(j)))*abs(cos(w(j)))^epsilon(2);
y(i,j)=a(2)*(a(4)+sign(cos(eta(i)))*abs(cos(eta(i)))^epsilon(1))*sign(sin(w(j)))*abs(sin(w(j)))^epsilon(2);
z(i,j)=a(3)*sign(sin(eta(i)))*abs(sin(eta(i)))^epsilon(1);
endfor;
endfor;
mesh(x,y,z);
endfunction;