28th January 2003 23:13 UTC
Ever wanted to make a torus....
Okay. I have had a lot of requests for a parameterisation for a torus. Here is one complete with explaination:
where u and v are the parameters (u from -pi to pi or spread over any 2pi wide interval)
x=(r*(cos(v)+1)+R)*cos(u));
y=r*sin(v);
z=-(r*(sin(v)+R)*sin(u));
Where r is the radius of one of the circles from a slice through the torus (the minor radius) and R is the radius of the circle made up from the centres of all of the circles comprising the torus (the major radius). The way that I made this parameterisation is pretty simple. Firstly I defined a circle in the xy plane with x=cos(v),y=sin(v) then offset it in the x axis by R+r. The final step was to rotate the circle parametrically around the y axis using the y-axis rotation matrix with u as the rotation angle to create a helix that would bend round into a torus.
Unfrotunately this method can *not* be extended simply for n-tori. To find parameterisations for these shapes you would need to rotate the circle first in the desired way and then shift it around a 3 dimensional path... something that I can't be bothered to work out right how to do right now.
NOTE: There may be better/faster parameterisations for the torus, this is just the easiest one to workout.