+/*static*/ double Vector::AngleBetween(Vector a, Vector b)
+{
+ // This is done using the following formula:
+ // (a . b) = ||a|| ||b|| cos(theta)
+ // However, have to check for two degenerate cases, where a = cb:
+ // 1) if c > 0, theta = 0; 2) if c < 0, theta = 180°.
+ // Also, the vectors a & b have to be non-zero.
+ // Also, have to check using an epsilon because acos will not return an
+ // exact value if the vectors are orthogonal.
+ if (a.isZero() || b.isZero())
+ return 0;
+
+ return acos(a.Dot(b) / (a.Magnitude() * b.Magnitude()));
+}