floripy.mathutils package#
Submodules#
floripy.mathutils.cholesky module#
floripy.mathutils.degree_4_angles module#
floripy.mathutils.eulang module#
floripy.mathutils.gauss module#
floripy.mathutils.geometry module#
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.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.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.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.xform module#
- 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.rotate_vector_axis_angle(v, axis, angle)[source]#
Rotates vectors about axis by angle.
- 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.rotate_vector_euler(v, euler, seq='XYZ', world=True)[source]#
Rotates vectors about axis by angle.
- floripy.mathutils.xform.get_inverted_quat(q)[source]#
Inverts a quaternion and returns it as a new instance.
- floripy.mathutils.xform.get_normalized_quat(q)[source]#
Normalizes a quaternion and returns it as a copy.
- floripy.mathutils.xform.get_angle_between_quat(p, q)[source]#
Returns the angle between two quaternions p and q.