08-18-2007 07:50
I've gotten very lost on my math with this one, and all my code (while working) is completely wrong mathematically.

What I want to do is feed in a set of 3 coordinates such as [<1,0,0>,<0.7071,0.7071,0>,<0,1,0>] and it will produce a circular torus so that the center of the tube passes through all 3 points, with the beginning cut starting at the first coordinate, and the ending cut finishing with the 3rd coordinate.

I've been trying to write the code based off "simple" point sets, such as the one given, but when I try to extrapolate that code to more non-simple cases such as [<1,2,.5>,<-3,1,3>,<2,-.75,2>] my very simplified math falls apart. Does anyone have some code, or even insight into translating how SL builds a torus (outer-edge radius, inner "hole", and the x,y,z stretches) compared to the standard mathematical definition of a torus:

x=(R+r*cos(v))*cos(u)
y=(R+r*cos(v))*sin(u)
z=r*sin(v)

where R is the radius from the center to the middle of the tube, r is the radius of the tube, and u,v = [0,2pi)
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.