Jump to content
  • Advertisement
Sign in to follow this  
johnnyBravo

How to rotate a point around an axis using a Quaternion?

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

I want to rotate a point around an axis using a Quaternion. I found a pdf article on gamedev, though I had a bit of trouble trying implement it. Heres what I tried from the article:
Vector v(3,0,0); //the point

Quaternion q(Vector(0,1,0)*(pi/4.0)); //the rotation quaternion (axisangle)

Quaternion p = Quaternion(1, v.x, v.y, v.z); //w,x,y,z

Quaternion r = q * p * q; 



I'm not sure if what I am doing is correct, and how I am to get the new position from r? Thanks

Share this post


Link to post
Share on other sites
Advertisement
vector4 quat::RotateVector (vector4 v)
{
quat t;
t.w = 0;
t.x = v.x;
t.y = v.y;
t.z = v.z;

quat h;
h.w = w;
h.x = x;
h.y = y;
h.z = z;

quat p = h * t * h.Conjugate ();

vector4 a ( p.x, p.y, p.z );

return a;
}



That's how I do it.

-Chris

Is there no [ code ] tag here? EDIT: source...Ok. Thanks.

[Edited by - easyBob0101 on March 21, 2007 10:10:37 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.

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

Sign me up!