angle_vectors_signed

compas.geometry.angle_vectors_signed(u, v, normal, deg=False, tol=None)[source]

Computes the signed angle between two vectors.

Returns the smallest angle between 2 vectors, with the sign of the angle based on the direction of the normal vector according to the right hand rule of rotation.

Parameters:
u[float, float, float] | compas.geometry.Vector

XYZ components of the first vector.

v[float, float, float] | compas.geometry.Vector

XYZ components of the second vector.

normal[float, float, float] | compas.geometry.Vector

XYZ components of the plane’s normal spanned by u and v.

degbool, optional

If True, returns the angle in degrees.

tolfloat, optional

The tolerance for comparing values to zero. Default is TOL.absolute.

Returns:
float

The signed angle in radians (in degrees if deg == True).

Examples

>>> normal = [0.0, 0.0, 1.0]
>>> angle_vectors_signed([0.0, 1.0, 0.0], [1.0, 0.0, 0.0], normal)
-1.57079