Angle Between Two Vectors (VEX)
The angle \( \theta \) is the inverse cosine of the fraction of dot product of the vectors \(\vec{a}\) and \(\vec{b}\) and the product of the magnitudes of \(\vec{a}\) and \(\vec{b}\).
\(\theta = \cos^{-1}\biggl({{\vec{a} \bullet \vec{b}} \over {\vert \vec{a} \vert\vert \vec{b} \vert}}\biggr)\)
In VEX code:
vector a = v@vector_a; vector b = v@vector_b; float angle; angle = acos( (dot(a,b)) / (length(a)*length(b)) ); //radians angle *= 180/PI; //convert to degrees
If you’re interested in why this is true, here’s a few links to helpful resources: