# Rotation of vector by a quaternion

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

## 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 on other sites
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.

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 18
• 20
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633364
• Total Posts
3011516
• ### Who's Online (See full list)

There are no registered users currently online

×