floripy.mathutils package#

Submodules#

floripy.mathutils.cholesky module#

floripy.mathutils.cholesky.decomp_LTL(A, overwrite=False, zero_upper=True, out=None)[source]#

floripy.mathutils.degree_4_angles module#

floripy.mathutils.eulang module#

floripy.mathutils.eulang.rotmat_euler(euler, seq='XYZ', world=True)[source]#
floripy.mathutils.eulang.factor_rotmat(rotmat, seq='XYZ', world=True)[source]#
floripy.mathutils.eulang.rotmat_XYZ(phi, theta, psi)[source]#
floripy.mathutils.eulang.factor_rotmat_XYZ(rotmat)[source]#
floripy.mathutils.eulang.rotmat_XZY(phi, theta, psi)[source]#
floripy.mathutils.eulang.factor_rotmat_XZY(rotmat)[source]#
floripy.mathutils.eulang.rotmat_YXZ(phi, theta, psi)[source]#
floripy.mathutils.eulang.factor_rotmat_YXZ(rotmat)[source]#
floripy.mathutils.eulang.rotmat_YZX(phi, theta, psi)[source]#
floripy.mathutils.eulang.factor_rotmat_YZX(rotmat)[source]#
floripy.mathutils.eulang.rotmat_ZXY(phi, theta, psi)[source]#
floripy.mathutils.eulang.factor_rotmat_ZXY(rotmat)[source]#
floripy.mathutils.eulang.rotmat_ZYX(phi, theta, psi)[source]#
floripy.mathutils.eulang.factor_rotmat_ZYX(rotmat)[source]#

floripy.mathutils.gauss module#

floripy.mathutils.geometry module#

floripy.mathutils.geometry.get_sector_angles(vertices_xy, center=[0.0, 0.0])[source]#
floripy.mathutils.geometry.get_degree4_dihedral_angles(sa, beta)[source]#
floripy.mathutils.geometry.get_dihedral_angle_between_polys(poly1, poly2, edge)[source]#

Returns the dihedral angle between two polygons sharing an edge.

floripy.mathutils.geometry.polygon(vertices)[source]#
floripy.mathutils.geometry.fit_ellipse(vertices)[source]#

Fits an ellipse to a parallelogram.

floripy.mathutils.gram module#

This module contains routines to perform Gram-Schmidt orthonormalization on a sequence of vectors.

floripy.mathutils.gram.gso(A, overwrite=False, out=None)[source]#

Performs Gram-Schmidt orthonormalization on a sequence of vectors.

Parameters:
Andarray

(M x N) ndarray with M <= N. The rows of A contain the sequence of vectors.

overwritebool, optional

If True, the matrix A is overwritten.

outndarray, optional

(M x N) ndarray with M <= N. The rows of out contain the sequence of orthonormal vectors. If overwrite = True, out is neglected.

Returns:
outputndarray

(M x N) ndarray with M <= N. The rows of out contain the sequence of orthonormal vectors.

Notes

See Golub and Van Loan, Matrix Computations, 3rd edition, Section 5.2.8, Algorithm 5.2.5, p. 231.

floripy.mathutils.linalg module#

floripy.mathutils.linalg.unitized(r)[source]#
floripy.mathutils.linalg.unitize(r)[source]#
floripy.mathutils.linalg.is_unitized(r)[source]#
floripy.mathutils.linalg.perm_tensor()[source]#

This function returns the permutation tensor.

floripy.mathutils.linalg.cross_mat(r)[source]#
floripy.mathutils.linalg.decomp_LTL(A, overwrite=False, zero_upper=True, out=None)[source]#

floripy.mathutils.realpoly module#

floripy.mathutils.transform module#

This module contains functions to convert Euler angles to Euler parameters and vice-versa. The Euler parameters are defined thus:

ep0 = cos(theta/2) ep1 = n_1*sin(theta/2) ep2 = n_2*sin(theta/2) ep3 = n_3*sin(theta/2) where n_1, n_2, and n_3 are the three components of an unit vector. Look at https://pyrr.readthedocs.org/en/latest/index.html if useful.

All angles are in radians.

floripy.mathutils.transform.perm_tensor()[source]#

This function returns the permutation tensor.

floripy.mathutils.transform.generate_eulerparam()[source]#

Generates a random set of Euler parameters.

floripy.mathutils.transform.generate_axisangle()[source]#

Generates a random pair of axis-angle. The axis ia a random vector from the surface of a unit sphere. Algorithm from Allen & Tildesley p. 349. Angle is a random number from [0.0, 2*pi).

floripy.mathutils.transform.eulerparam2eulerangle(ep)[source]#

This function converts Euler Parameters to Euler Angles. Euler Angles represent 3-1-3 (z-x-z) rotation. See Eq(2.143) of DMS.

floripy.mathutils.transform.axisangle2eulerparam(axis, angle)[source]#

Converts axis angle to Euler Parameters. Ref. Eq(2.10) of DMS.

floripy.mathutils.transform.rotation_matrix2eulerangle(rotmat, order, body_fixed=True)[source]#
Ref: Dmitry Savransky and N. Jeremy Kasdin, An Efficient Method for

Extracting Euler Angles from Direction Cosine Matrices, http://spaceisbig.net/docs/findEulerAngs.pdf

floripy.mathutils.transform.rotation_matrix2eulerparam(rotmat)[source]#

Converts rotation matrix to Euler parameters. http://www.gamasutra.com/view/feature/131686/rotating_objects_using_quaternions.php

floripy.mathutils.transform.eulerparam2axisangle(ep)[source]#

Converts Euler Parameters to axis angle. Ref. Invert Eq(2.10) of DMS.

floripy.mathutils.transform.eulerangle2eulerparam(ea, order='313', fixed='body')[source]#

This function converts Euler Angles (3-1-3 or z-x-z rotation) to Euler parameters. See Eq(2.142) of DMS.

floripy.mathutils.transform.any2eulerparam(orientation)[source]#

orientation is a dict.

floripy.mathutils.transform.shifter_decomp_E(ep)[source]#

Create the shifter decomposition matrices from the Euler parameters. These matrices are denoted by E and Ebar. See Eq(2.22) and (2.23) of DMS.

floripy.mathutils.transform.shifter_decomp_Ebar(ep)[source]#

Create the shifter decomposition matrices from the Euler parameters. These matrices are denoted by E and Ebar. See Eq(2.22) and (2.23) of DMS.

floripy.mathutils.transform.shifter(ep)[source]#

Create the shifter matrix from the given Euler parameters. See Eq(2.14) of DMS.

floripy.mathutils.transform.rotation_matrix(axis, angle)[source]#

Returns the matrix describing the rotation about axis <axis> by angle <angle>.

floripy.mathutils.transform.epdot2ang_vel_transform_mat(ep)[source]#

Returns the matrix that transforms epdot to angular velocity vector. Ref: Eq(2.58) of DMS.

floripy.mathutils.transform.epdot2ang_vel(ep, epdot)[source]#

Returns the angular velocity vector from epdot. Ref: Eq(2.58) of DMS.

floripy.mathutils.transform.ang_vel2epdot_transform_mat(ep)[source]#

Returns the matrix that transforms epdot to angular velocity vector. Ref: Invert Eq(2.58) of DMS, using the fact that the sum of the squares of the Euler parameters is unity, and the resulting 4x4 matrix will be orthogonal. Hence the inverse is its transpose. Now throw away the last column as it multiples the 4th component of ang_vel (= 0). The factor of half appears as there is a factor of 2 in the pre-inverted equation.

floripy.mathutils.transform.ang_vel2epdot(ep, ang_vel)[source]#

Returns epdot from the angular velocity vector. Ref: Invert Eq(2.58) of DMS. See the note in the docstring of the function ang_vel2epdot_transform_mat.

floripy.mathutils.transform.ang_vel_mat(ang_vel)[source]#

Depending on whether omega is global or local, Omega will be the global or local angular velocity matrix.

floripy.mathutils.transform.shifter_dot(S, ang_vel)[source]#

S: shifter Angular velocity can be obtained from epdot if desired.

floripy.mathutils.transform.cross_mat(r)[source]#
floripy.mathutils.transform.dcm(B, A)[source]#

C_ij = a_i . b_j. Gives the orientation of B frame w.r.t A frame. A and B are (3,3) matrices whose rows give the corresponding coordinate axis.

floripy.mathutils.transform.dcm_to_euler_angles(dm, seq=[1, 2, 3], space=False)[source]#
floripy.mathutils.transform.main()[source]#

floripy.mathutils.xform module#

floripy.mathutils.xform.fix_axis_angle(axis, angle, normalize=True)[source]#
floripy.mathutils.xform.get_rand_axis_angle()[source]#

Generates a random pair of axis-angle. The axis is a random vector from the surface of a unit sphere. Algorithm from Allen & Tildesley p. 349.

floripy.mathutils.xform.axis_angle_to_quat(axis, angle)[source]#
floripy.mathutils.xform.axis_angle_to_euler(axis, angle, seq='XYZ', world=True)[source]#
floripy.mathutils.xform.axis_angle_to_dcm(axis, angle)[source]#
floripy.mathutils.xform.any_to_axis_angle(orientation)[source]#
floripy.mathutils.xform.rotate_vector_axis_angle(v, axis, angle)[source]#

Rotates vectors about axis by angle.

floripy.mathutils.xform.get_rotmat_axis_angle(axis, angle)[source]#
floripy.mathutils.xform.extract_axis_angle_from_rotmat(rotmat)[source]#
floripy.mathutils.xform.shift_vector_axis_angle(v, axis, angle, forward=False)[source]#
floripy.mathutils.xform.shift_tensor2_axis_angle(a, axis, angle, forward=False)[source]#
floripy.mathutils.xform.shift_tensor3_axis_angle(a, axis, angle, forward=False)[source]#
floripy.mathutils.xform.get_shiftmat_axis_angle(axis, angle, forward=False)[source]#
floripy.mathutils.xform.dcm_from_axes(A, B)[source]#

Returns the direction cosine matrix of axes(i.e. frame) B w.r.t. axes(i.e. frame) A.

Parameters:
A(3,3) ndarray

The rows of A represent the orthonormal basis vectors of frame A.

B(3,3) ndarray

The rows of B represent the orthonormal basis vectors of frame B.

Returns:
(3,3) ndarray

The dcm of frame B w.r.t. frame A.

floripy.mathutils.xform.dcm_to_quat(dcm)[source]#
floripy.mathutils.xform.dcm_to_euler(dcm, seq='XYZ', world=True)[source]#
floripy.mathutils.xform.dcm_to_axis_angle(dcm)[source]#
floripy.mathutils.xform.any_to_dcm(orientation)[source]#
floripy.mathutils.xform.rotate_vector_dcm(v, dcm)[source]#
floripy.mathutils.xform.get_rotmat_dcm(dcm)[source]#
floripy.mathutils.xform.shift_vector_dcm(v, dcm, forward=False)[source]#
floripy.mathutils.xform.shift_tensor2_dcm(a, dcm, forward=False)[source]#
floripy.mathutils.xform.shift_tensor3_dcm(a, dcm, forward=False)[source]#
floripy.mathutils.xform.get_shiftmat_dcm(dcm, forward=False)[source]#
floripy.mathutils.xform.factorize_rotmat(rotmat, seq='XYZ', world=True)[source]#
floripy.mathutils.xform.euler_to_euler(euler, seq, world, to_seq, to_world)[source]#
floripy.mathutils.xform.euler_to_quat(euler, seq='XYZ', world=True)[source]#
floripy.mathutils.xform.euler_to_dcm(euler, seq='XYZ', world=True)[source]#
floripy.mathutils.xform.euler_to_axis_angle(euler, seq='XYZ', world=True)[source]#
floripy.mathutils.xform.any_to_euler(orientation, to_seq, to_world)[source]#
floripy.mathutils.xform.rotate_vector_euler(v, euler, seq='XYZ', world=True)[source]#

Rotates vectors about axis by angle.

floripy.mathutils.xform.get_rotmat_euler(euler, seq='XYZ', world=True)[source]#
floripy.mathutils.xform.shift_vector_euler(v, euler, seq='XYZ', world=True, forward=False)[source]#
floripy.mathutils.xform.shift_tensor2_euler(a, euler, forward=False)[source]#
floripy.mathutils.xform.shift_tensor3_euler(a, euler, forward=False)[source]#
floripy.mathutils.xform.get_shiftmat_euler(euler, seq='XYZ', world=True, forward=False)[source]#
floripy.mathutils.xform.get_identity_quat()[source]#
floripy.mathutils.xform.get_rand_quat()[source]#
floripy.mathutils.xform.get_perturbed_quat(q)[source]#
floripy.mathutils.xform.quat_to_axis_angle(q)[source]#
floripy.mathutils.xform.quat_to_euler(q, seq='XYZ', world=True)[source]#
floripy.mathutils.xform.quat_to_dcm(q)[source]#
floripy.mathutils.xform.any_to_quat(orientation)[source]#
floripy.mathutils.xform.rotate_vector_quat(v, q)[source]#
floripy.mathutils.xform.get_rotmat_quat(q)[source]#
floripy.mathutils.xform.shift_vector_quat(v, q, forward=False)[source]#
floripy.mathutils.xform.shift_tensor2_quat(a, quat, forward=False)[source]#
floripy.mathutils.xform.shift_tensor3_quat(a, quat, forward=False)[source]#
floripy.mathutils.xform.get_shiftmat_quat(q, forward=False)[source]#
floripy.mathutils.xform.conjugate_quat(q)[source]#

Conjugates a quaternion in-place.

floripy.mathutils.xform.get_conjugated_quat(q)[source]#

Conjugates a quaternion and returns a copy.

floripy.mathutils.xform.invert_quat(q)[source]#

Inverts a quaternion in-place.

floripy.mathutils.xform.get_inverted_quat(q)[source]#

Inverts a quaternion and returns it as a new instance.

floripy.mathutils.xform.normalize_quat(q)[source]#

Normalizes a quaternion in-place.

floripy.mathutils.xform.get_normalized_quat(q)[source]#

Normalizes a quaternion and returns it as a copy.

floripy.mathutils.xform.quat_is_normalized(q)[source]#
floripy.mathutils.xform.get_quat_prod(p, q)[source]#
floripy.mathutils.xform.interpolate_quat(q1, q2, t)[source]#
floripy.mathutils.xform.get_angle_between_quat(p, q)[source]#

Returns the angle between two quaternions p and q.

floripy.mathutils.xform.quat_deriv_to_ang_vel(q, qdot)[source]#
floripy.mathutils.xform.quat_deriv_to_ang_vel_mat(q)[source]#
floripy.mathutils.xform.ang_vel_to_quat_deriv(q, ang_vel)[source]#
floripy.mathutils.xform.ang_vel_to_quat_deriv_mat(q)[source]#
floripy.mathutils.xform.translate(v, delta)[source]#

Translates vectors inplace by delta.

floripy.mathutils.xform.align(v, old, new)[source]#

old and new represent coordinate axes. They must be unit vectors.

floripy.mathutils.xform.mat_is_dcm(mat)[source]#
floripy.mathutils.xform.mat_is_rotmat(mat)[source]#

Module contents#