Function lupnt::AngleBetweenVecs(const VecX&, const VecX&)

Function Documentation

Real lupnt::AngleBetweenVecs(const VecX &x, const VecX &y)

Compute the angle between two vectors.

Angle between two vectors [rad], computed via the numerically robust 2*atan2(|n1-n2|, |n1+n2|) formula (avoids the precision loss of acos(dot) near 0 and pi), where n1, n2 are the normalized inputs.

Parameters:
  • x – First vector

  • y – Second vector

  • x – First vector

  • y – Second vector

Returns:

Angle between the two vectors in radians

Returns:

Angle between x and y [rad], in [0, pi]