|
BamBam Sachertorte
floral engineer
Join date: 12 Jul 2005
Posts: 228
|
01-11-2008 13:23
I am writing a geodesic dome script (I know that there are others, I just want to write one). I can't seem to get the rotation of the triangular faces right. I have three points for the triangle, p0, p1, and p2 and I am trying to rez a thin prism prim with corners at those three points. The following code almost works for setting the rez rotation but almost all of the faces are slightly off. What am I doing wrong?
<php> vector left = p1 - p2; vector up = (p0 - p2) % (p1 - p2); vector fwd = left % up; rotation rot = llAxes2Rot(fwd, left, up); </php>
|
|
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
|
01-11-2008 13:27
You want to normalise stuff before you throw it into llAxes2Rot.
_____________________
-Seifert Surface 2G!tGLf 2nLt9cG
|
|
BamBam Sachertorte
floral engineer
Join date: 12 Jul 2005
Posts: 228
|
01-11-2008 21:05
Woo Hoo! Thanks Seifert! Now it works perfectly.
I wonder why llAxes2Rot doesn't just normalize the vectors for us? I should update the LSL Portal to note that the vectors must be mutually orthogonal unit vectors.
|
|
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
|
01-11-2008 21:14
It might be a small bit of efficiency, assuming that the incoming stuff is normalised already? And if you know that it should be normalised, then you can manage to be a bit more efficient than if it automatically did it every time...
_____________________
-Seifert Surface 2G!tGLf 2nLt9cG
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
01-11-2008 22:22
If you normalize the first two orthogonal vectors, the third should already be normal after the last cross product, too. Or very, very close (close enough I've never had any problems with it).
|