angle_btw¶
Angle between two \(n\)-dimensional vectors.
Typically, the angle between two vectors v1 and v2 can be obtained with:
However, this approach is numerically unstable. The version provided here is numerically stable and based on the AngleBetweenVectors Julia package by Jeffrey Sarnoff (MIT license), implementing an algorithm provided by Prof. W. Kahan in these notes (see page 15).
Arguments¶
v1- First vector.v2- Second vector.
Return values¶
a- Angle betweenv1andv2in radians.