Archived

This topic is now archived and is closed to further replies.

Quaternion manipulation

This topic is 5989 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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?

Share on other sites
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

Share on other sites
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]

1. 1
Rutin
49
2. 2
3. 3
4. 4
5. 5

• 11
• 16
• 9
• 10
• 13
• Forum Statistics

• Total Topics
633003
• Total Posts
3009848
• Who's Online (See full list)

There are no registered users currently online

×