MATLAB: Angle between two vectors in 3d

3danglevectors

Hello,
I have two vectors in 3d and i want to find the angle between those two vectors.
Thanks in advance

Best Answer

Or:
angle = atan2(norm(cross(a,b)), dot(a,b))
See this compact discussion about this topic: CSSM: Angle between two vectors . Only 71 replies (Google finds 89 replies, so I assume 18 spam messages?) and 68300 views currently...
[EDITED]: W. Kahan suggested in his paper "Mindeless.pdf":
2 * atan(norm(x*norm(y) - norm(x)*y) / norm(x * norm(y) + norm(x) * y))