Jump to content
  • Advertisement
Sign in to follow this  

3d rotation about a vector

This topic is 5109 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'm having a problem orientating a camera in 3d space. The camera's position and direction are stored in three vectors: position, direction and an up vector. I want to be able to move the camera freely, like in space simulators such as Elite or Descent. In a first person shooter type game, the camera can be rotated by applying a rotation about the axis, e.g. rotate about the y axis to look left and right. However, I want to be able to move the camera, independent of the axis. I think I need a rotation matrix which works about a vector. Then I can apply this about the up vector to look left and right. I've googled for this topic but I haven't found anything particularly useful. Am I taking the right approach?

Share this post

Link to post
Share on other sites
Arbitrary axis rotation:

void RotateVector(float Angle, Vector3 *VecToRotAbout, Vector3 *VecToRotate)
float cosTheta = (float)cos(Angle);
float sinTheta = (float)sin(Angle);
Vector3 proj = *VecToRotAbout * DotProduct(VecToRotAbout,VecToRotate);
(CrossProduct(*VecToRotAbout, *VecToRotate)*sinTheta)+

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!