[Math] How to convert a dot product of two vectors to the angle between the vectors.

geometryvectors

I am currently learning to use normalized vectors in the computer games I'm creating.

I've learned that in order to know "the angle" between two vectors, I need to use Dot Product. This gives me a value between $1$ and $-1$. $1$ means they're parallel to each other, facing same direction (aka the angle between them is $0^\circ$). $-1$ means they're parallel and facing opposite directions ($180^\circ$). And $0$ means the angle between them is $90^\circ$.

But I want to know, how to convert the dot product of two vectors, to an actual angle in degrees.

For example, if the dot product of two vectors is $0.28$. How can I convert it to an actual angle, between $0^\circ$ to $360^\circ$?

Thank you

Best Answer

The dot product of two normalized vectors is equal to the cosine of the angle between them. In general $$\cos \phi = \frac{a\cdot b}{|a||b|},$$ since your vectors are normalized, $|a|=|b|=1$ and $\phi = \arccos(a\cdot b)$