PDA

View Full Version : How to find angle betw camera and rotated object axis?



blood.angel
02-01-2002, 12:25 PM
My camera is positioned at (0,0,10).
Now when an object is rotated the axis moves with the object. I wish to find the angle betw the axis and the camera vector (using dot product).
Can anyone help?

Furrage
02-04-2002, 06:40 AM
Given A is the angle between two vectors B and C then
B.C = |B| * |C| * cos(A) = Bx * Cx + By * Cy + Bz * Cz

Thus the angle between these vectors, in radians, is given by
A = acos(dot(B, C) / (mod(B) * mod(C)))

Hope that helps.