Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Yet another rotation question

Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
07-13-2008 15:53
I'm looking to get the *global* rotation of a prim with it's *local* Z-axis rotation zeroed out. I don't actually want to rotate it, I just want to get its *global* rotation as it would be if its *local* Z-axis rotation was zeroed.

Any clues would be gratefull received.
Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
07-13-2008 16:06
This seems to give me what I want

vector euler = llRot2Euler( llGetRot());
rotation rot = llEuler2Rot( < euler.x, euler.y, 0>;);

but something I'm doing when I try to use it is wrong. Grrr.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
07-15-2008 10:57
I think you're going to have to better define what you mean by a zero rotation about the local z-axis. What does that mean in terms of the prim's axes? For example, if the prim's local z-axis is pointed in the same direction as global <1,1,1>, which way would it's x- and y-axes be pointing?

More precise definitions might be more along the lines of:

A.) When rotated about the local z-axis so that the local x-axis is in the global xz-plane.
B.) When rotated about the local z-axis to a point where the rotation differs from ZERO_ROTATION by a simple rotation about an axis in the global xy-plane.

or something like that. You'll have to decide what definition you really mean. Think of it in terms of what the physical object is doing, not in terms of the very artificial Euler angles.
Xhawkx Holden
Registered User
Join date: 1 Nov 2006
Posts: 86
07-15-2008 15:54
Anya.. try this maybe??

vector euler = llRot2Euler( llGetRot());
rotation rot = llEuler2Rot( < euler.x, euler.y, euler.z + <euler.x, euler.y, euler.z*-1>;);

I seem to recall something about how SL calculates the Euler rotations, and that it may modify one of the x, y, or z entries and zero another to get the same angle. Adding the negative of the Z might actually give the correct answer you are looking for.

Just a thought
Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
07-15-2008 17:58
Thanks. The two lines I posted seem to get the angle I need. I don't know why my previous code didn't work, but when I took a long look at it I found an easier way, which had the fortunate side effect or working correctly.