commonlibs.math package¶
Submodules¶
commonlibs.math.interpolation module¶
Interpolation
commonlibs.math.vectors module¶
Vectors
-
commonlibs.math.vectors.
angle_between
(vector1, vector2)[source]¶ Return the angle in radians between vectors ‘vector1’ and ‘vector2’
- # See also: https://stackoverflow.com/questions/2827393/
angles-between-two-n-dimensional-vectors-in-python/13849249#13849249
-
commonlibs.math.vectors.
axis_rot_matrix
(axis, angle)[source]¶ Return a rotation matrix associated with counterclockwise rotation about a given axis by angle radians.
- Note:
The rotation matrix is computed using the Euler-Rodrigues formula: https://en.wikipedia.org/wiki/Euler%E2%80%93Rodrigues_formula
- Args:
- axis
3x1 axis vector
- angle
rotation aangle in radians
- Returns:
- R
rotation matrix
-
commonlibs.math.vectors.
direction_cosine
(vector1, vector2)[source]¶ Returns the direcion cosine between vectors ‘vector1’ and ‘vector2’
See also:
- Args:
- vector1
First vector
- vector2
Second vector
- Returns:
- direction_cosine
Direction cosine
-
commonlibs.math.vectors.
get_plane_line_intersect
(plane_normal, plane_point, line_direction, line_point, epsilon=1e-06)[source]¶ Get the intersection point for a line and a plane in 3D space.
- Note:
The line is defined by its direction (vector) and any point on the line
The plane is defined by its normal (vector) and any point on the plane
- Args:
- plane_normal
3x1 normal vector of the plane
- plane_point
point (3x1 vector) of the plane (any)
- line_direction
3x1 vector with the direction of the line
- line_point
point (3x1 vector) of the line (any)
- epsilon
tolerance for near-orthogonal ‘plane_normal’ and ‘line_direction’
-
commonlibs.math.vectors.
rotate_vector_around_axis
(vector, axis, angle, return_unit=False)[source]¶ Rotate a vector by an angle around a defined axis.
Note:
Returns the original vector if the Euclidean norm of ‘vector’ or ‘axis’ is zero or if ‘angle’ is zero
- Args:
- vector
Vector to be rotated
- axis
3x1 axis vector
- angle
Rotation angle in radians
- Returns:
- rot_vector
rotated vector
-
commonlibs.math.vectors.
vector_projection
(a, b)[source]¶ Return the vector projection from vector a onto vector b
- See:
- Args:
- a
vector to be projected
- b
vector onto which a is projected
- Returns:
- a1
vector projection
-
commonlibs.math.vectors.
vector_projection_onto_plane
(vector, plane_normal)[source]¶ Project a vecor onto a plane
- Args:
- vector
vector to be projected
- plane_normal
normal vector of the plane
- Returns:
- vector_proj
projected vector