fast_forward.linalg_functions module

Collection of linear algebra functions mostly related to geometry operations.

fast_forward.linalg_functions.apply_rotation(vec_to_rotate, rotation_axis, rad_angle)[source]

Rotate a vector around an axis by a given angle. .. note:: The rotation axis is a vector of 3 elements.

Parameters:
Returns:

1D array The final rotated (normalized) vector.

Return type:

ndarray

fast_forward.linalg_functions.calc_rotation_matrix(quaternion)[source]

Translate a quaternion to a rotation matrix.

Parameters:

quaternion (ndarray) – numpy 1D-array of 4 elements.

Returns:

numpy 2D-array (dimension [3, 3]) The rotation matrix.

Return type:

ndarray

fast_forward.linalg_functions.cross_product(A, B)[source]

Return the cross product between vectors A & B. Source: http://hyperphysics.phy-astr.gsu.edu/hbase/vvec.html.

Note

On small vectors (i.e. of 3 elements), computing cross products with this functions is faster than np.cross().

Parameters:
  • A (ndarray) – A vector of 3 elements.

  • B (ndarray) – Another vector of 3 elements.

Returns:

Cross product of A^B.

Return type:

ndarray

fast_forward.linalg_functions.dihedral_angle(r1, r2, r3)
fast_forward.linalg_functions.u_vect(vect)

Compute unit vector of vector.

Parameters:

vect (ndarray)

Return type:

ndarray

fast_forward.linalg_functions.vec2quaternion(vec, theta)[source]

Translate a vector of 3 elements and angle theta to a quaternion.

Parameters:
  • vec (ndarray) – Vector of the quaternion.

  • theta (float) – Angle of the quaternion in radian.

Returns:

The full quaternion (4 elements).

Return type:

ndarray

fast_forward.linalg_functions.vector_angle(v1, v2)

Compute the angle between two vectors.

Parameters:
Return type:

float

fast_forward.linalg_functions.vector_angle_degrees(v1, v2)

Compute the angle between two vectors in degrees and between 0 180 degrees.

Parameters:
Return type:

float