Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Function to convert tilt/spin/roll to a quat?

Scalar Tardis
SL Scientist/Engineer
Join date: 5 Nov 2005
Posts: 249
11-24-2005 21:50
Okay, I admit it. I'm a moron.

I never took linear algebra in skool. I have no clue what a quaternion is, or why in the world you'd keep track of an object's 3-dimensional rotation using FOUR numbers? What the...?

I am looking for a simple script function that accepts a vector datatype containing three rotational values in degrees (not radians) just like in the SL object editor window, and outputs a rotation quat.


To rotate a prim to an absolute rotation of +10.0 degrees tilt/x, -10 degrees yaw/y, +5.01 degrees roll/z, I'd like to be able to do something stupid-simple like this:

vector primspin = <+10.0, -10.0, +5.01>;
rotation primrot = QuatFunctionForIdiots(primspin);



With such a function, I assume this could be done for relative rotation:

rotation primrot = llGetLocalRot();
vector primspin = <+10.0, -10.0, +5.01>;
primrot = primrot + QuatFunctionForIdiots(primspin);


Next question. Does a function like this alreafy exist? Since I don't know what Euler functions are or any of that, I'm not sure how to find this function if does exist. :)
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
11-24-2005 22:03
CODE
vector targetrot = <10.0, -5.0, 20.0>; // Degrees rotation
rotation myrotation = llEuler2Rot(targetrot * DEG_TO_RAD); // quanternionification
rotation final_target = llGetRot() * myrotation; //"adds" rotations together
_____________________
Scalar Tardis
SL Scientist/Engineer
Join date: 5 Nov 2005
Posts: 249
11-24-2005 22:25
Ah, thank goodness it's not so hard... unless you want it to be. :)
Travis Lambert
White dog, red collar
Join date: 3 Jun 2004
Posts: 2,819
12-21-2005 22:49
This post saved my life tonight.... Thanks! :)
_____________________
------------------
The Shelter

The Shelter is a non-profit recreation center for new residents, and supporters of new residents. Our goal is to provide a positive & supportive social environment for those looking for one in our overwhelming world.