Jump to content
  • Advertisement
Sign in to follow this  
avion85

Rotation of vector by a quaternion

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

What is the best way to rotate a vector with a quaternion? As i see it, there is no dedicated way to do this within d3d(i use d3d9). There are a number of functions like: D3DXVec3Transform D3DXVec3TransformArray D3DXVec3TransformCoord D3DXVec3TransformCoordArray that transform a vector using a matrix, but none directly using a quaternion. So what is better to do, transform a quaternion to a matrix, and then use this matrix to transform my vector, or go "ground level" and do it myself like this:
vector rotate_with_quaternion(quaternion q, vector v)
  Quaternion t;
  t = q*v*(~q);   //~q is conjugate quaternion
return t.get_vector_component();

but then i need to define operators for vector-quaternion multiplication, and the whole thing gets complicated... What do you think? Maybe there is a third way? thanks

Share this post


Link to post
Share on other sites
Advertisement
If you want to transform more than one vector by a given quaternion then it's generally more efficient to transform the quaternion to a matrix and then transform all the vectors you want by that matrix.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!