Jump to content
  • Advertisement
Sign in to follow this  
derek7

quaternion and matrix

This topic is 4618 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

We know transform a point by point * matrix. but it come to quaternion ,it work too? can I use point * quaternion to transform a point? I must convert quaternion to matrix???

Share this post


Link to post
Share on other sites
Advertisement
The matrix.Transform() functions uses quaternations as parameters, so this would be a good function to use for that, if I understand you correctly.

Share this post


Link to post
Share on other sites
You can rotate a point directly by converting it to a quaternion and multiplying it by the rotation and the inverse of the rotation:
    q   = rotation
q-1 = inverse (also conjugate) of q
p = point to rotate
p' = rotated point

[p', 0] = q * [p, 0] * q-1

Share this post


Link to post
Share on other sites
Quote:
Original post by JohnBolton
You can rotate a point directly by converting it to a quaternion and multiplying it by the rotation and the inverse of the rotation:
    q   = rotation
q-1 = inverse (also conjugate) of q
p = point to rotate
p' = rotated point

[p', 0] = q * [p, 0] * q-1


What is [P,0] ? do you mean:

[D3DXVECTOR3(x',y',z') ,0] = q * [[D3DXVECTOR3(x,y,z) ,0]] q-1

Share this post


Link to post
Share on other sites
Hi!

I'm not experienced with this stuff but i think what John wanted to say is:

A quaternion q is made up of the x, y, z and w compontent.

So [p', 0] means there is ie. a quaternion u' with

u'.x = p'.x;
u'.y = p'.y;
u'.z = p'.z;
u'.w = 0;

and [p,0] means there is a quaternion u with

u.x = p.x;
u.y = p.y;
u.z = p.z;
u.w = 0;


where p' is the rotated point and p the point you wanted to rotate.

so what you should do is creating two Quaternions. One(u') for the rotated point(p') and one(u) for the point you want to rotate(p).

should be something like:

D3DXVECTOR3 p = new D3DXVECTOR3(x,y,z);
D3DXQUATERNION q = ...;
D3DXQUATERNION u = D3DXQUATERNION(p.x, p.y, p.z, 0);
D3DXQUATERNION qInv = D3DXQUATERNIONInverse(null, q);
D3DXQUATERNION u' = q * u * qInv;

So p' = D3DXVECTOR3(u'.x, u'.y, u'.z);

John wrote:

q = rotation Quaternion
q-1 = inverse (also conjugate) of q
p = point to rotate
p' = rotated point

[p', 0] = q * [p, 0] * q-1

I hope, this will help you!
(and that i got it right ;) )

Martin

[Edited by - gammaGT on November 30, 2005 10:16:52 AM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!