Coverage for navipy/maths/euler.py : 91%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" rotation matrix around the x- axis
:param a: angle in degrees to be rotated :returns: a matrix :rtype: (np.ndarray) ..ref: James Diebel "Representing Attitude: Euler Angles, Unit Quaternions, and Rotation Vectors." (2006): p. 5 (2.4). """ raise TypeError("angle must be numeric value") [0, c(a), s(a)], [0, -s(a), c(a)]])
""" rotation matrix around the y- axis
:param a: angle in degrees to be rotated :returns: a matrix :rtype: (np.ndarray) ..ref: James Diebel "Representing Attitude: Euler Angles, Unit Quaternions, and Rotation Vectors." (2006): p. 5 (2.4). """ raise TypeError("angle must be numeric value") [0, 1, 0], [s(a), 0, c(a)]])
""" rotation matrix around the z- axis
:param a: angle in degrees to be rotated :returns: a matrix :rtype: (np.ndarray) ..ref: James Diebel "Representing Attitude: Euler Angles, Unit Quaternions, and Rotation Vectors." (2006): p. 5 (2.4). """ raise TypeError("angle must be numeric value") [-s(a), c(a), 0], [0, 0, 1]])
""" rotation matrix around the three axis with the order given by the axes parameter
:param ai: angle in degrees to be rotated about the first axis :param aj: angle in degrees to be rotated about the second axis :param ak: angle in degrees to be rotated about the third axis :returns: a matrix :rtype: (np.ndarray) ..ref: James Diebel "Representing Attitude: Euler Angles, Unit Quaternions, and Rotation Vectors." (2006): p. 9 """ raise ValueError("the chosen convention is not supported") np.dot(matrixes[j](aj), matrixes[k](ak)))
"""Return Euler angles from rotation matrix for specified axis sequence.
axes : One of 24 axis sequences as string or encoded tuple
Note that many Euler angle triplets can describe one matrix. ..ref: James Diebel "Representing Attitude: Euler Angles, Unit Quaternions, and Rotation Vectors." (2006): p. 23 - 31. """ raise TypeError("matrix must be np.array or list") raise ValueError("the chosen convention is not supported") # if np.any(np.isnan(np.array(matrix, dtype=np.float64))): # raise ValueError('posorient must not contain nan') #matrix = np.transpose(matrix) # if rot: # matrix = np.transpose(matrix) # new = list(axes) # new[0] = 's' # axes = ''.join(new) np.arccos(matrix[0, 0]), np.arctan2(matrix[0, 1], -matrix[0, 2])] -np.arcsin(matrix[0, 2]), np.arctan2(matrix[0, 1], matrix[0, 0])] np.arccos(matrix[0, 0]), np.arctan2(matrix[0, 2], matrix[0, 1])] np.arcsin(matrix[0, 1]), np.arctan2(-matrix[0, 2], matrix[0, 0])] np.arccos(matrix[1, 1]), np.arctan2(matrix[1, 0], matrix[1, 2])] np.arcsin(matrix[1, 2]), np.arctan2(-matrix[1, 0], matrix[1, 1])] -np.arcsin(matrix[1, 0]), np.arctan2(matrix[1, 2], matrix[1, 1])] np.arccos(matrix[1, 1]), np.arctan2(matrix[1, 2], -matrix[1, 0])] -np.arcsin(matrix[2, 1]), np.arctan2(matrix[2, 0], matrix[2, 2])] np.arccos(matrix[2, 2]), np.arctan2(matrix[2, 0], -matrix[2, 1])] np.arcsin(matrix[2, 0]), np.arctan2(-matrix[2, 1], matrix[2, 2])] np.arccos(matrix[2, 2]), np.arctan2(matrix[2, 1], matrix[2, 0])] else: print("conv", axes, matrix) raise KeyError('convention not in {}', _AXES2TUPLE.keys())
"""Return Euler angles from quaternion for specified axis sequence. """ not isinstance(quaternion, list): raise TypeError("quaternions must be np.array or list") # if np.any(np.isnan(np.array(quaternion, dtype=np.float64))): # raise ValueError('posorient must not contain nan')
""" Return the Euler Angle Rates Matrix
from Diebels Representing Attitude: Euler Angles, Unit Quaternions, and Rotation, 2006 rotation matrix around the three axis with the order given by the axes parameter
:param ai: angle in degrees to be rotated about the first axis :param aj: angle in degrees to be rotated about the second axis :param ak: angle in degrees to be rotated about the third axis :param axes: string representation for the order of axes to be rotated around and whether stationary or rotational axes should be used :returns: a matrix :rtype: (np.ndarray) ..ref: James Diebel "Representing Attitude: Euler Angles, Unit Quaternions, and Rotation Vectors." (2006): p. 9 (5.2) """ raise TypeError("euler angle must be of type float") # if np.isnan(np.array([ai], dtype=np.float64)) or\ # np.isnan(np.array([aj], dtype=np.float64)) or\ # np.isnan(np.array([ak], dtype=np.float64)): # raise ValueError("quaternions must not be nan or none")
""" Return the angular velocity
:param ai: angle in degrees to be rotated about the first axis :param aj: angle in degrees to be rotated about the second axis :param ak: angle in degrees to be rotated about the third axis :param dai: time derivative in degrees/time of the angle to be rotated about the first axis :param daj: time derivative in degrees/time of the angle to be rotated about the second axis :param dak: time derivative in degrees/time of the angle to be rotated about the third axis :param axes: string representation for the order of axes to be rotated around and whether stationary or rotational axes should be used :returns: a matrix :rtype: (np.ndarray) ..ref: James Diebel "Representing Attitude: Euler Angles, Unit Quaternions, and Rotation Vectors." (2006): p. 9 (5.2) """ raise TypeError("euler angle time derivative must be of type float") # if np.isnan(np.array([ai], dtype=np.float64)) or\ # np.isnan(np.array([aj], dtype=np.float64)) or\ # np.isnan(np.array([ak], dtype=np.float64)): # raise ValueError("quaternions must not be nan or none") # if np.isnan(np.array([dai], dtype=np.float64)) or\ # np.isnan(np.array([daj], dtype=np.float64)) or\ # np.isnan(np.array([dak], dtype=np.float64)): # raise ValueError("quaternions must not be nan or none") |