pytransform3d.rotations.angle_between_vectors#
- pytransform3d.rotations.angle_between_vectors(a, b, fast=False)[source]#
Compute angle between two vectors.
\[\theta = 2 \operatorname{atan2} \left( \left\| \|b\| a - \|a\| b \right\|, \left\| \|b\| a + \|a\| b \right\| \right)\]See [1], page 47. To simplify the implementation, we normalize both vectors first such that norms of 1 cancel.
- Parameters:
- aarray-like, shape (n,)
nd vector
- barray-like, shape (n,)
nd vector
- fastbool, optional (default: False)
Use fast implementation instead of numerically stable solution
- Returns:
- anglefloat
Angle between a and b
References
[1]Kahan, W. (2006). How Futile are Mindless Assessments of Roundoff in Floating-Point Computation? https://people.eecs.berkeley.edu/~wkahan/Mindless.pdf