Skip to main content
GameDev.net gamedev.net
🔒 Locked

Quaternion manipulation

Started by Maverick the divider May 31, 2002 at 1:13 PM 1 replies 750+ views
Original Post
Maverick the divider
Maverick the divider
Maybe anyone can explain one simple thing about quaternions. Like, i have a quaternion to do my rotation, but if i multiply it over my orientation quaternion, it''s frame-dependant movement. So is there a way to have a part of the rotation aplied or will i have to generate new quaternions each time?
---Quite soon...ICQ: 163187735
NickWaanders
NickWaanders
I''m not exactly sure what you mean, but I think it has something to do with adding a ''rotation velocity'' to the rotation, right?

Say your rotation velocities are stored in a vector3 called ''omega'', and the current orientation of your object is in a quaternion called ''q''. To proceed to the next frame with a certain ''deltaTime'' I use the following step:

quat qdot(q * quat(vector3(omega.x, omega.y, omega.z), 0.0f) * 0.5f);
qnew = q + (qdot * deltaTime);
qnew.Normalize();

This should give you the new orientation ''qnew'', which you can then (after checking if there are collisions in your scene you might have to resolve) put into the orientation of the object.

Hope this is what you were searching for..

Nick
Maverick the divider
Maverick the divider
Hmm, my object turns around anywhere he wants, this is what i've done:

if (Engine->_Input->KeyDown(DIK_A)) {
D3DXQUATERNION qdot;
D3DXQuaternionDot(&qdot, &(D3DXQUATERNION(0, 0.02f, 0, 0) * 0.5f));
qOrientation = qOrientation * (qdot * Elapsed);
D3DXQuaternionNormalize(&qOrientation, &qOrientation);
}

[edited by - Maverick the divider on May 31, 2002 12:43:27 AM]
---Quite soon...ICQ: 163187735

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.