Jump to content
  • Advertisement
Sign in to follow this  
CAHI4

Angle between two vectors about arbitrary axis...

This topic is 4269 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
Advertisement
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)
and
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);
*VecToRotate=
(*VecToRotate-proj)*cosTheta+
(CrossProduct(*VecToRotAbout, *VecToRotate)*sinTheta)+
proj;
}


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!