Notifications
Clear all

[Closed] How to find the angle betwen two vectors

I got two vectors A and B as Point3, how could I find the 3 eulerangles between them, I look in the manual but I can’t find a “simple” method to do it.
What I wan’t to do is to copy the result rotation on to other object rotations.

Thank you in advance.

3 Replies

Hi,
I think you can use quats. Here’s my idea: calculate cross product of A and B. Put its x,y,z into quat’s x,y,z. Thats your rotation vector, now you need angle. Equation is very simple:
ang = acos((A.xB.x+A.yB.y+A.zB.z) / ((length A)(length B))). ang is w part of quat. Now simply convert quat to eulerangles using “as eulerangles”. I think it should work but never tried that.

Look up “Dot Product” in the MS reference manual.

There is actually only one angle between two vectors (in relation to eachother). You can get that value like this:

ang = acos (dot vec1 vec2)

Note that the vectors must be normalized.

To get the angle of a vector in worldspace you’re gonna hafta use some trig.