Page 1 of 1

Detemining rotation required.

Posted: Sun Feb 24, 2008 6:48 pm
by LittleGiant

Code: Select all

InnerLib::vector3f vDirection1, vDirection2;
InnerLib::quaternion4f q;

q.rotationFromTo( vDirection2, vDirection1 );
q.makeInverse();

Rotate( q ); // Do the actual rotation
This is the basic code i'm using right now, assume the 2 vectors have good values.

So my goal here is to figure out the rotation that needs to be applied to vDirection2 so that it is oriented the same as vDirection1, i then want to do that rotation( but the Rotate function does other things as well, hence my need to actually know that rotation amount ).

Any help would be great suggestions on what i might be doing wrong, or other ways to calculate this, currently i get what seem like gimbal lock issues.

Re: Detemining rotation required.

Posted: Mon Feb 25, 2008 11:28 am
by rogerborg
LittleGiant wrote:So my goal here is to figure out the rotation that needs to be applied to vDirection2 so that it is oriented the same as vDirection1,
This code would do that:

Code: Select all

	f32 length = vDirection2.getLength();
	vDirection2 = vDirection1;
	vDirection2.setLength(length);
Does that do what you want, or did I misinterpret?

Posted: Tue Feb 26, 2008 5:23 am
by LittleGiant
Sort of, you accomplish the change on the vector but the rotation needed to accomplish this is the important piece of information i need. Because i need to use it to rotate other dependencies.