skspatial.objects.Vector.angle_signed_3d

Vector.angle_signed_3d(other: Union[ndarray, Sequence], direction_positive: Union[ndarray, Sequence]) float[source]

Return the signed angle in radians between the vector and another.

The vectors must be 3D.

Parameters
otherarray_like

Other main input vector.

direction_positivearray_like

A vector perpendicular to the plane formed by the two main input vectors.

Returns
np.float64

Signed angle between vectors in radians.

Raises
ValueError

If the vectors are not 3D. If the positive direction vector is not perpendicular to the plane formed by the two main input vectors.

Notes

This method uses the convention of right-handed rotation.

References

https://stackoverflow.com/questions/5188561/signed-angle-between-two-3d-vectors-with-same-origin-within-the-same-plane

Examples

>>> import numpy as np
>>> from skspatial.objects import Vector
>>> np.degrees(Vector([1, 0, 0]).angle_signed_3d([0, -1, 0], direction_positive=[0, 0, 2]))
-90.0
>>> np.degrees(Vector([1, 0, 0]).angle_signed_3d([0, -1, 0], direction_positive=[0, 0, -5]))
90.0
>>> Vector([1, 0]).angle_signed_3d([1, 0], [1, 0, 0])
Traceback (most recent call last):
...
ValueError: The vectors must be 3D.
>>> Vector([1, 0, 4]).angle_signed_3d([1, 0, 5], [1, 0])
Traceback (most recent call last):
...
ValueError: The vectors must be 3D.