Jump to content
  • Advertisement
Sign in to follow this  

Angle between two vectors about arbitrary axis...

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

Look, i have three points, one center point and two another points that's make vectors(they'r have equal length) with center point, and suppose i have some another vector(arbitrary axis), and i need to know angle that rotate one vector to anoterh about this axis. Can anyone help me?

Share this post

Link to post
Share on other sites
Project them onto a plane perpendicular to the axis. e.g. if your vectors are a and b, and the axis is n, then asssuming n is a unit vector

c = a - n * (a . n)
d = b - n * (b . n)

lie in a plane through the origin perpendicular to the axis, and the angle between them is the angle you want. They are not in general unit vectors, so to get the angle between them you need something like

arccos ((c . d) / (|c| * |d|))

Share this post

Link to post
Share on other sites
A function that rotates a vector around an arbitrary axis. I can explain it in more detail if you ask.

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!