Computes the angle in \([0, \pi]\) between two numeric vectors using the
dot-product/acos formula, with the dot product clamped to
\([-1, 1]\) for numerical stability near colinear and anti-colinear
configurations.
Details
For unit vectors the formula is
$$\theta = \arccos(v_1 \cdot v_2);$$
for general vectors, divide the dot product by the product of the norms
before applying acos. The implementation assumes pre-normalised
input and only clamps the dot product to the unit interval.
References
Strang, G. (2016). Introduction to Linear Algebra, 5th edition. Wellesley-Cambridge Press. ISBN 978-0980232776.
See also
lhuilier_angle for the spherical excess of a triangle whose
sides are returned by this function; spherical_triangle_area
for the Van Oosterom-Strackee form; cross_product_3d for the
associated 3D vector product.