# 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.

## 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 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)
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|))

Thnx :)

##### 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;}

• 10
• 17
• 9
• 14
• 41
• ### Forum Statistics

• Total Topics
631067
• Total Posts
2997738
×