Generating the torus and helitoroid

A parametric representation of a torus:

T (u,v)=(cos(u)(R+rsin(v)), sin(u)(R+rsin(v)) , rcos(v)),    for    0 u   2π,      0 v  2π in which  T (u,v) is the position vector of a general point on the surface,                 R is the major radius of the torus,                 r  is the minor radius, i.e., the radius of the tube.

This torus is in a standard position, but we can move it to different positions or orientations in space by applying coordinate transformations.

I begin the construction of the helitoroid with the parametric definition of a directrix curve:

h ( u ) = R ( cos ( u ) ,   sin ( u ) ,   0 )   +   r ( sin ( W u ) cos ( u ) ,   sin ( W u ) sin ( u ) ,   cos ( W u ) ) ,         for    0   u      2 π

in which W is a positive integer, which I call the winding. This curve moves at constant distance r from the major circle, which is the circle of radius R in the plane z=0, centered at the origin, and it closes on its tail after winding around the major circle W times.

As for any smooth space curve, we get the tangent vector t ^ (u) to the directrix curve at any point as the unit vector in the direction of the derivative of the position vector with respect to the parameter. h ˙ (u)= d du h (u) t ^ (u)= h ˙ (u)/ h ˙ (u)
The dots on top mean derivative. The hat on t ^ (u) signifies unit vector. means length of vector.

The derivative of the tangent vector is perpendicular to it. (Exercise for the reader: convince yourself from elementary vector calculus definitions that the derivative of a unit vector function is perpendicular to it.)

So we let

t ^ ˙ ( u ) = d d u t ^ ( u ) n ^ ( u ) = t ^ ˙ ( u ) / t ^ ˙ ( u )

The unit vector n ^ (u) is called the normal vector to the curve.   The plane through the point h ( u )   spanned by t ^ (u)  and n ^ (u)  is called the osculating plane.  The projection of the space curve on the osculating plane is the plane curve that best  approximates the space curve in a small neighborhood of h ( u ) .

So t ^ (u)  and n ^ (u)  are two perpendicular unit vectors. Their cross product

b ^ ( u ) = t ^ ( u ) × n ^ ( u )

is called the curve binormal and { t ^ (u) n ^ (u) b ^ (u)} form an orthonormal frame, which moves along the curve with the parameter u, and is called the Frenet frame. This frame is the context for the beautiful theory of smooth space curves. See the books by Dirk Struik or Barrett O'Neill for good introductions (Chapter 1 in both).

The vectors n ^ (u)  and   b ^ (u) span the plane through the point  that's perpendicular to the tangent  of the directrix curve .   I generate my  helitoroid surface by inflating the directrix curve to a tube of cross section radius ρ .  For any given point h (u) on the directrix curve, the points on the circle of radius ρ about h (u) in the plane perpendicular to the directrix curve are parameterized by

H (u,v) =  h (u) + ρ(cos(v)  n ^ (u) + sin(v)  b ^ (u))      for   0  v  2π

Thus, letting u  vary over its full range, we get the (doubly) parametric representation of the helitoroid surface :

H ( u , v )   =   h ( u )   +   ρ ( cos ( v )   n ^ ( u )   +   sin ( v )   b ^ ( u ) )      for    0 u 2 π ,    0     v     2 π

For any values of the two parameters, the quantities on the right can be calculated from the original definition of h (u) and the formulas of elementary vector calculus.   You can see the code that implements  them in the JavaScript.  Note that  there are a lot of terms that come from evaluating the first and second derivatives, and substantial computing for the cross products and the normalizations. Note how much more compact and intuitive than the code is this presentation in vector math notation.

The tessellation of each of these surfaces is obtained by evaluating the position vectors on an integer lattice in the 2D parameter domain,  and the quads thus formed are bisected to form triangles.  The two surfaces in the current example comprise  12000 triangles. 

Also, for the smooth shading I need normal vectors to the both surfaces at each vertex of the tessellations.  Symmetry considerations show that the helitoroid surface normal at each point is

cos(v)  n ^ (u)+sin(v)  b ^ (u)

and the torus surface normal at each point is

(cos(u)sin(v),   sin(u)sin(v),   cos(v))

which both are computed in the course of computing the  vertex positions. 

Powered by MathJax