Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotation around edge not axis

Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
05-29-2007 05:42
OK - I found TONS of scripts 'n hints about rotation - but every script I found always rotated the object around the center of the object.
But I need to rotate it around the edge. Say, I hava a box and now want to rotate that box around a corner of the box. AND - and this is the problem: without linking the box to another prim (which would be the easiest way, then I just rotate the small attached prim and thus the box would rotate with it...)...

Hope I wasn't to vague...

Thanks for every hint in advance!
White Hyacinth
Registered User
Join date: 15 Nov 2006
Posts: 353
05-29-2007 06:12
What you need to do is make your box smaller with the path cut settings in the edit box. This will make it look like it rotates on the edge.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
Cool!
05-29-2007 06:26
Thanks a lot - sounds like a good idea! I'll try that! :)))
Lyn Mimistrobell
(waiting)
Join date: 11 Jan 2007
Posts: 179
05-29-2007 07:03
Sometimes you can't use a cut (depending on the shape of the object you want to rotate) in which case you can use a combination of llSetPos and llSetRot (or together in an llSetPrimitiveParams) to make it look like it rotated on a different virtual axis. It won't look as good as a normal rotation but the endresult will be ok.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
thanks again
05-29-2007 08:00
I thought of this as well, but actually feared the math I'd have to do to compute the new location depending on the rotation and the size of the prim... I'm sure there's a way though... and I hope I'll figure out... ;)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-29-2007 08:23
From the wikki

From: wikki
Combining Rotations
An object is rotated by multiplying its current orientation with the desired rotation. The order in which the operands are specified depends if a rotation is performed around the global axes or the local axes.

Example:
// a rotation of 45 degrees around the x-axis
rotation x_45 = llEuler2Rot( <45 * DEG_TO_RAD, 0, 0> );

rotation new_rot = llGetRot() * x_45; // compute global rotation
llSetRot(new_rot); // orient the object accordinglyThis rotates the object around the global x-axis (the axis which runs from west to east).

Now consider the following:
rotation new_rot = x_45 * llGetRot(); // compute local rotation
llSetRot(new_rot); // orient the object accordinglyThis rotates the object around its local x-axis, which depends on its current orientation. Think of this as specifying the rotation from the object's point of view, that is, relative to the direction it is currently facing.

This also works Inversely by Dividing two rotations:
rotation new_rot = x_45 / llGetRot(); // compute local rotation
llSetRot(new_rot); // orient the object accordinglyLike previously, this would rotate your object along the x-axis based on its current orientation, but in the opposite direction.

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 point of rotation. This vector will be the "new location" the object should be moved to.
_____________________
I'm back......
Dnali Anabuki
Still Crazy
Join date: 17 Oct 2006
Posts: 1,633
05-29-2007 09:20
There is a way to change the axis to the edge of a rectangle.
Rez a sphere. Size 1, .120, 1. Dimple B. .500, E 1.00. Change sphere to box and axis should be to the edge now. Put in rotation script and it will turn on the edge with some script fiddling. Saves a prim anyway and great for doors.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
Helped! :)
05-30-2007 03:57
I well read this wikki-entry, but honestly... I didn't get it... (maybe I should go a little deeper into vectors 'n stuff... :)

The last entry with rezzing a sphere and fumbling around with dimple and then change it to a box helped and works perfectly... :)

Thanks a lot to all of you!
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
05-30-2007 08:44
heyas;

there's my edge rotation function if you really, really, desperately, absolutely need to rotate around an edge.

/54/85/170765/1.html
_____________________
Why Johnny Can't Rotate:
http://forums.secondlife.com/showthread.php?t=94705