Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
08-25-2005 12:21
I'm making a follower totally legally, that needs to follow its target and rotate to face the same way.
Sadly it needs physics to move right to do this.
So I know my current rot (llGetRot()) and the target object's rot (llDetectedRot()). Typically I need to be at pi/2 around z to follow with the right angle - is there a nicer way of doing that than converting to euler adding the pi/2 and converting back?
Is there a nice way of working out what rotational impulse I need to get the two to have the same rotation in a given time?
Currently I've got an ugly hack, detecting every second, moving with a tau of 0.95 then using llSetRot(), which gives jerking movement, and I suspect flicking physics on and off like that is probably worse on the sim than having it on whenever the target is moving.
|
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
|
08-25-2005 12:36
Why not use llRotLookAt? And you need to rotate it around the z axis? llRotLookAt(llDetectedRot(0) * <0.0,0.0,1.0,1.0>  if that isn't quite it try llRotLookAt(<0.0,0.0,1.0,1.0> * llDetectedRot(0)) I have the hardest time remembering what the order of operations do for quaternion multiplication If you find it's rotating in the wrong direction just make the 3rd or 4th element of the rotation negative (either one just not both).
_____________________
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
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
08-25-2005 13:08
Stupidity?
I knew there was an easy way to do it, I just missed it in the list. Thanks Strife.
|
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
|
08-25-2005 16:25
From: Strife Onizuka I have the hardest time remembering what the order of operations do for quaternion multiplication I find it useful to remember that if you rotate a vec, the order is: vec * rot So if you apply two rotations, you're doing: (vec * rot1) * rot2 == vec * (rot1 * rot2) ...because associativity has to work or something is very wrong. So the one on the left gets applied first, the one on the right second.
_____________________
-Seifert Surface 2G!tGLf 2nLt9cG
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
08-25-2005 17:20
Since I've opened this again can someone explain how a vector (3 X 1) times a quat (1 X 4 for ease) gives a vector (3 X 1) again? I'd expect a 3 X 4 matrix answer...
And that Strife, tried it out and it all works a treat.
|
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
|
08-25-2005 18:10
I think it's like this... Vector v; Quaternion q;
Vector r; //Result
r = <v.x*q.x,v.y*q.y,v.z*q.z> //Is identical to r = r*q; But then again, I might be wrong.
|
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
|
08-26-2005 00:47
From: Eloise Pasteur Since I've opened this again can someone explain how a vector (3 X 1) times a quat (1 X 4 for ease) gives a vector (3 X 1) again? I'd expect a 3 X 4 matrix answer...
And that Strife, tried it out and it all works a treat. They're not "multiplying" as matrix multiplication. It's better to think of it as applying a rotation to a vector. If you start with a vector, and rotate it around some axis, you'll get another vector. I don't think you really need to get further into the guts of it to be able to do whatever you want to do.
_____________________
-Seifert Surface 2G!tGLf 2nLt9cG
|