Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

question about converting rotations

Geuis Dassin
Filming Path creator
Join date: 3 May 2006
Posts: 565
05-18-2006 08:02
Im working on this and maybe I'll figure it out, but I'm kinda confused.

I'm doing a rotation on a prim. I know how to do it using degrees but I'm not sure how to do it with llGetRot and such. (yeah, I've been reading about quaternions and such).

degRot = current degrees I'm converting from.

answer = (degRot - 180);
if(answer < 0){ answer += 360;}

So I know that I have to use llGetRot to get the current rotation. That's returned in quat's.

This is where I get confused, I think I have to convert the quats to degrees.

vector eul = llRot2Euler(llGetRot());

So llRot2Euler gives me what I thought are degrees, but they look like floats and not degrees. I'm not sure how to convert from this point.

Any ideas?
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
05-18-2006 08:07
llRot2Euler will give you units in the ultimately more sensible radians.

Multlipling your output vector by the constant RAD_TO_DEG will convert it to degrees.

NB, you'll still get floats as the result, although if you're lucky you'll get a lot of floats with .000000 on the end...

llEuler2Rot wants radians in it's vector too, not degrees. DEG_TO_RAD is your friend there.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
05-18-2006 08:11
First, what are you trying to do?
If you are just trying to rotate something 180 degrees around a single axis, then it's pretty simple.

If you want to rotate something 180 degrees around the x axis, you do.
CODE

//<1.0, 0.0, 0.0, 0.0> = llEuler2Rot(<180.0, 0.0, 0.0> * DEG_TO_RAD)
rotation change = <1.0, 0.0, 0.0, 0.0>;
llSetRot(llGetRot() * change)

Speaking in generalizations, you should not be manipulating the rotation of an object with Eulers, it's just a headace. It's a good rule, to convert your Eulers to Quaternions (rotations) and work with them in that form.

PS: If it rotates in the wrong way (IE you want it to rotate not around the local axis but the world axis) switch around the order in the llSetRot, so it's change * llGetRot().
_____________________
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
Geuis Dassin
Filming Path creator
Join date: 3 May 2006
Posts: 565
05-18-2006 08:26
Well this is my problem.

I'm using Jeff's Magic Mirror to duplicate an object Im making but that I need a mirror image of.

It works great, except for the fact that some of the prims have directional particle effects with a zero directional velocity, so they project in the direction the object they're attached to is rotated.

What's happening is that when those prims are being mirrored, its mirroring the rotation as well so my particle jets point in exactly the opposite direction.

I've been able to correct this by manually doing the equation I mentioned above. However, doing this manually really sucks. Plus I want to write a tool that I can use in the future.

For example, the rotation of one object was x=317.65 y=332.75 z=115.40. After I do the conversions, the proper rotation is x=137.65 y=152.75 z=295.4.

So I'm trying to find an equation that will properly do this equation for me.