Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Can anyone reproduce this example?

Eubarch Moose
Registered User
Join date: 1 Sep 2005
Posts: 2
09-10-2005 17:38
This is the example from the wiki, concerning a technique to rotate a primitive about a point that is not its center of mass. In theory, the vector math is sound. However, when I run this script sequence, even copied verbatim, I get no rotation whatsoever.

Here's the page: http://secondlife.com/badgeo/wakka.php?wakka=Rotation

And the specific example is at the bottom:


From: someone

When rotating a vector, the rotation must appear to the right of the vector:

vector new_vec = old_vec * x_45; // compiles
vector new_v = x_45 * old_v; // doesn't compile

Note: An object can be rotated around an arbitrary point by multiplying a vector by a rotation in the manner described above. The vector should be the difference between the object's current position and the desired "center-point" of rotation. Take the result of the multiplication and add it to the object's current position. This vector will be the "new location" the object should be moved to.

vector currentPos = llGetPos();
vector rotPoint = llGetPos() + <1, 1, 1>; // in global coordinates
vector newPos = rotPoint + ((currentPos - rotPoint) * x_45);
llSetPos(newPos);




On a cube primitive, this code segment produces no change. The cube is set to ZERO_ROTATION. What's going on?
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
09-10-2005 18:26
The last 4 lines should deal with altering the position of the rotated object, when you want to rotate about a point other than its center. They won't actually rotate the object though, just move it. You still need this bit to do the rotation:
CODE
rotation new_rot = x_45 * llGetRot();  // compute local rotation
llSetRot(new_rot); // orient the object accordingly
_____________________
-Seifert Surface
2G!tGLf 2nLt9cG