eddymotion.math.utils module

eddymotion.math.utils.compute_angle(v1, v2, closest_polarity=False)[source]

Compute the angle between two vectors.

Parameters:
  • v1 (ndarray) – First vector.

  • v2 (ndarray) – Second vector.

  • closest_polarity (bool) –

    True to consider the smallest of the two angles between the crossing

    lines resulting from reversing both vectors.

Returns:

The angle between the two vectors in radians.

Return type:

float

Examples

>>> compute_angle(
...     np.array((1.0, 0.0, 0.0)),
...     np.array((-1.0, 0.0, 0.0)),
... )  
3.1415...
>>> compute_angle(
...     np.array((1.0, 0.0, 0.0)),
...     np.array((-1.0, 0.0, 0.0)),
...     closest_polarity=True,
... )
0.0
eddymotion.math.utils.is_positive_definite(matrix)[source]

Check whether the given matrix is positive definite. Any positive definite matrix can be decomposed as the product of a lower triangular matrix and its conjugate transpose by performing the Cholesky decomposition. :Parameters: matrix (ndarray) – The matrix to check.

Return type:

True is the matrix is positive definite; False otherwise