Karyn Kuhr
Registered User
Join date: 23 Jul 2005
Posts: 7
|
11-02-2005 05:46
I've already done this the long way, but is there a simple way to turn a rotation into a unit vector describing the direction an object is pointing ?
As it happens I'm only concerned about the z axis rotation as it gives me a heading for an object travelling only in the x,y plane, if that makes it easier.
My current method is as follows:
rotation myRot = llGetRot(); vector myEulerRot = llRot2Euler(myRot); float myHeading = myEulerRot.z; float myXcomponent = llCos(myHeading); float myYcomponent = llSin(myHeading); myUnitVector = <myXcomponent,myYcomponent,0>
I just thought a 1 line vector/rotation math expression might do the same thing...
I have half an idea quaternions actually work something like this anyway.
Thanks in advance to any maths people who can help !
|
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
|
11-02-2005 06:51
llRot2Fwd(the_rotation); will return a unit vector pointing forward of the given rotation  There are also llRot2Up and llRot2Left. If you just need a global-Z orientation, then get the llRot2Fwd vector, put 0 as its z component and use the norm of this new vector  vector temporary = llRot2Fwd(llGetRot()); temporary.z = 0.0; vector my_unit_vector = llVecNorm(temporary);
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
|
Karyn Kuhr
Registered User
Join date: 23 Jul 2005
Posts: 7
|
11-02-2005 06:57
thanks very much ! it's so obvious now you point it out 
|