Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Combining 2 GOOD rotations makes a wrong one

Stone Juran
Registered User
Join date: 21 Mar 2007
Posts: 28
05-08-2007 04:09
Hello,

I am trying to make an eye-like object. It works very well on a single axis.

I made it work around the Z axis, it's great!
I made it work around the Y axis, it's great too!

but now, i wanted to combine these two rotations: my eye seems sick, it points to nowhere interesting, but it moves...

have a look at the script:
CODE

vector eulbeta;
vector eulgamma;

// Here i compute BETA and gamma
//...

eulbeta= <0,beta,0>;
eulgamma= <0,0,gamma>;

quatbeta = llEuler2Rot(eulbeta);
quatgamma = llEuler2Rot(eulgamma);

quat = quatbeta*quatgamma; // This line does not work
// if i replace it by : quat = quatbeta; it works for one axis
// if i replace it by : quat = quatgamma; it works for one axis

llSetRot(quat); //rotate the object


Can you help me?

Thank you
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
god help us all...
05-08-2007 09:07
how about q = llEuler2Rot( < 0, beta, gamma > );
Senuka Harbinger
A-Life, one bit at a time
Join date: 24 Oct 2005
Posts: 491
05-08-2007 09:59
I could have sworn that you divided rotations to combine them in SL (which is the opposite way the math is supposed to work). Since you're not working entirely within quaternion values, why not combine your rotations while they're assigned an euler value (Gamma+beta) and then apply the rotation.
_____________________
My SLExchange shop

Typos are forgiven; desecrating the english language with reckless abandon and necrophilic acts is not.


The function is working perfectly fine. It's just not working the way you wanted it to work.
Ralph Doctorow
Registered User
Join date: 16 Oct 2005
Posts: 560
05-08-2007 10:29
To combine rotations you can multiply or divide. Multiply adds the rotations in the order of operations, dividing also adds them, but the divisors are done by rotating in the opposite direction.

That is, if you have a 1 R rotation and a .5 R rotation, 1*.5 rotates plus 1 radian, than plus .5 radians. 1/.5 first rotates plus 1 radian then minus .5 radians. (For clarity I'm only doing one axis)