Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Prim Rotation Issue

Thorne Kaiser
Nice Guy
Join date: 29 Nov 2005
Posts: 132
02-16-2006 07:37
When using:
CODE
llSetPrimitiveParams([PRIM_ROTATION, <0, 0, 0, 1>]);


If I set the rotation to 90 degrees, the prim rotates 178.5 degrees!
If I set it to 270, it still only rotates 178.5 degrees!
180....still 178.5 degrees! :(

CODE
llSetPrimitiveParams([PRIM_ROTATION, <0, 0, 90, 1>]);


So what gives? The prim is new and had not been rotated at all. It is the parent prim of 4 child prims. When it rotates 178.5 degrees, the other prims follow. Not sure what's the problem here.

If anyone can offer some help, I'd sure appreciate it.
Thanks!
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
02-16-2006 08:29
Rotation is measured in radians, not degrees.

And it's even more complex than that... read this.
Lindsey Dassin
Fallen Angel
Join date: 14 Sep 2005
Posts: 33
02-16-2006 09:37
Simple scripts like this have helped me out a lot for understanding rotations:

CODE

default {
touch_start() {
llOwnerSay( "llGetRot(): " + (string)llGetRot() );
llOwnerSay( "llGetLocalRot(): " + (string)llGetLocalRot() );
}
}
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
02-16-2006 10:02
Congratulations, you have stumbled upon the living hell of quaternion mathematics. An obscure area of math, that didn't become useful till computers came along. Don't even try and picture a quaternion, they are 4D; which is why they are divine for 3D rotational math. Like using an ICBM (inter-continental ballistic missile) to take out the trash. The trouble is few of us are rocket scientists.

The function you want is llEuler2Rot()

CODE

vectore degrees = <30,56,23>;
rotation rot = llEuler2Rot(degrees * DEG_TO_RAD);


Euler (a man who lived a few hundered years ago) predated quaternions, and as a result his methods make sense. Unfortunately they have horrible drawbacks (gimble lock, slerp is impossible). If Euler had been born later i'm sure he would have loved quaternions. Thankfuly for the rest of us he wasn't.

CODE

/\
/ \
/ \
/......\
/ _.~' \
/ <_| \
/ `-. \
| |
| |
__| _ |
__|__|__ {_/ } |
|________| |
| | |
|------+------------|
|------+------------|
| | ____/ |
|______| ____} |
| |
| |
| |
/| ^^ |\
/ | || | \
/ | || | \
/ | || | \
/ |______||______| \
/____/ || \____\
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Lindsey Dassin
Fallen Angel
Join date: 14 Sep 2005
Posts: 33
02-16-2006 14:57
Quaternions really aren't illogical or difficult: they're just a really abstract representation -- and they happen to be a LOT easier to manipulate numerically than either Euler or Axis-Rotation. Yes, quaternions are 4-D, which means you can't visualize what "w" (why do they call it "s"??), "x", "y", or "z" represent, but i still wouldn't call them incomprehensible.

If you've ever played with linear, analog circuitry with capacitors and inductors, you could think of quaternions as a kind of Laplace transformation for computer graphics. In the case of circuits like i described, if you try to directly, mathematically analyze them you end up with second-order differential equations: double-plus yuck! But, if you apply a Laplace transformation to the set of equations, you get linear equations that are a whole lot easier to manipulate (even though you can no longer really visualize what they mean). Then when is all said and done you map the end-result back into what we're used to seeing.

Having said all that...

I do not derive my rotations from the Euler(?) values in the "right-click" -> "Edit" window. I put a script like the above into an object and say "What's your rotation? ...... Okay, so what's your rotation now?" write them down, and put a few pre-defined rotation constants into my scripts.