# How to find rotation angles between two vectors

## Recommended Posts

Hi,

How to find rotation angles between two vectors?

Lets say Vector A = {0, 1, 0} and B = {1, 0, 0}, the angle between these vectors is 45.

We can find this angle by using combination of dot product and inverse cosine. But I would like to know the rotation vector like {45, 0, 0}

##### Share on other sites

Many thanks Edward that helps.

I would like to know the maths behind it, if you have idea could you share it?

##### Share on other sites

When you said "rotation vector" did you mean rotation matrix?

rotation_matrix.hipnc

##### Share on other sites

Many thanks Edward that helps.

I would like to know the maths behind it, if you have idea could you share it?

One way is to just derive the angle as you know how to do that already and then create a quaternion for it. Then you can either use the quaternion to rotate vectors directly, or convert into a rotation matrix if desired.

http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors

##### Share on other sites

Hey Dedeks,

I am actually looking for the opposite way, finding rotation matrix from two vectors.

But found the solution using align VOP. I want to know the maths behind it.

Thanks

##### Share on other sites

One way is to just derive the angle as you know how to do that already and then create a quaternion for it. Then you can either use the quaternion to rotate vectors directly, or convert into a rotation matrix if desired.

http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors

Thanks Edward,

This link give me clear understanding.

But Its weird that I got wrong result when I try to implement same logic in VEX, I might be doing something wrong.

I have attached my scene file.

find_rotation_v001.hipnc

Edited by kare

##### Share on other sites

You're missing some things like the acos() and the normalize() of the cross product.

Cool got it.

##### Share on other sites

This is from the maxscript (3dsmax) help docs, it shows the maths behind getting the angle between 2 vectors:

## Create an account

Register a new account