Math – ephemerista.math

The math.py module.

This module provides mathematical utility functions.

ephemerista.math.angle_between(v1, v2)

Return the angle in radians between vectors v1 and v2.

Return type:

float

Examples

>>> angle_between((1, 0, 0), (0, 1, 0))
1.5707963267948966
>>> angle_between((1, 0, 0), (1, 0, 0))
0.0
>>> angle_between((1, 0, 0), (-1, 0, 0))
3.141592653589793
ephemerista.math.cone_vectors(v1, theta_deg, angle_res_deg, include_endpoint=False)

Generate a set of vectors representing the surface of a cone.

Parameters:
  • v1 (numpy 3*1 array) – The cone’s axis vector

  • theta_deg (float) – The cone’s half aperture. Must be in the [-90, 90°] range.

  • angle_res_deg (float) – The angular resolution of the cone in degrees

Return type:

a n*3 numpy array containing the n vectors representing the cone surface

ephemerista.math.orthonormal_base_from_one_vec(v1)

Create an orthonormal base completing the given vector v1, using the Gram-Schmidt procedure.

Source: https://stackoverflow.com/questions/33658620/generating-two-orthogonal-vectors-that-are-orthogonal-to-a-particular-direction

Return type:

tuple[ndarray, ndarray, ndarray]

ephemerista.math.unit_vector(vector)

Return the unit vector of the given vector.

Return type:

ndarray