Detemining rotation required.

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
LittleGiant
Posts: 15
Joined: Wed Jun 02, 2004 1:53 am

Detemining rotation required.

Post 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.
LittleGiant
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Re: Detemining rotation required.

Post 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?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
LittleGiant
Posts: 15
Joined: Wed Jun 02, 2004 1:53 am

Post 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.
LittleGiant
Post Reply