Angle between two vectors about arbitrary axis...
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?
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|))
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|))
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;}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement