Rotations¶
- class py123d.geometry.Quaternion[source]¶
Represents a quaternion for 3D rotations.
Examples
>>> import numpy as np >>> from py123d.geometry import Quaternion >>> quat = Quaternion(1.0, 0.0, 0.0, 0.0) >>> quat.qw 1.0 >>> quat.qx 0.0 >>> quat.array array([1.0, 0.0, 0.0, 0.0]) >>> quat.rotation_matrix array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]])
Public Data Attributes:
qwThe scalar component of the quaternion.
qxThe x component of the quaternion.
qyThe y component of the quaternion.
qzThe z component of the quaternion.
arrayThe numpy array of shape (4,) containing the quaternion [qw, qx, qy, qz], indexed by
QuaternionIndex.pyquaternionThe pyquaternion.Quaternion representation of the quaternion.
euler_anglesThe
EulerAnglesrepresentation of the quaternion.rotation_matrixReturns the 3x3 rotation matrix representation of the quaternion.
Inherited from
ArrayMixinarrayThe array representation of the geometric entity.
shapeReturn the shape of the array.
Public Methods:
from_array(arr[, copy])Constructs a Quaternion from a numpy array.
from_rotation_matrix(rotation_matrix)Constructs a Quaternion from a 3x3 rotation matrix.
from_euler_angles(euler_angles)Constructs a Quaternion from Euler angles.
Inherited from
ArrayMixinfrom_array(array[, copy])Create an instance from a NumPy array.
from_list(values)Create an instance from a list of values.
tolist()Convert the array to a Python list.
to_list()Convert the array to a Python list.
copy()Return a copy of the object with a copied array.
- classmethod from_rotation_matrix(rotation_matrix)[source]¶
Constructs a Quaternion from a 3x3 rotation matrix.
- classmethod from_euler_angles(euler_angles)[source]¶
Constructs a Quaternion from Euler angles. NOTE: The rotation order is intrinsic Z-Y’-X’’ (yaw-pitch-roll).
- Parameters:
euler_angles (
EulerAngles) – An EulerAngles instance representing the Euler angles.- Return type:
- Returns:
A Quaternion instance.
- property array: ndarray[tuple[Any, ...], dtype[float64]]¶
The numpy array of shape (4,) containing the quaternion [qw, qx, qy, qz], indexed by
QuaternionIndex.
- property pyquaternion: Quaternion¶
The pyquaternion.Quaternion representation of the quaternion.
- property euler_angles: EulerAngles¶
The
EulerAnglesrepresentation of the quaternion.
- property rotation_matrix: ndarray[tuple[Any, ...], dtype[float64]]¶
Returns the 3x3 rotation matrix representation of the quaternion.
- copy()¶
Return a copy of the object with a copied array.
- Return type:
ArrayMixin
- class py123d.geometry.EulerAngles[source]¶
Class to represent 3D rotation using Euler angles (roll, pitch, yaw) in radians.
Examples
>>> import numpy as np >>> from py123d.geometry import EulerAngles >>> euler_angles = EulerAngles(roll=0.0, pitch=0.0, yaw=np.pi) >>> euler_angles.roll 0.0 >>> euler_angles.yaw 3.141592653589793 >>> euler_angles.array array([0.0, 0.0, 3.14159265]) >>> EulerAngles.from_rotation_matrix(euler_angles.rotation_matrix).yaw 3.141592653589793
Notes
The rotation order is intrinsic Z-Y’-X’’ (yaw-pitch-roll) [1].
References
Public Data Attributes:
rollThe roll (x-axis rotation) angle in radians.
pitchThe pitch (y-axis rotation) angle in radians.
yawThe yaw (z-axis rotation) angle in radians.
arrayConverts the EulerAngles instance to a numpy array of shape (3,), indexed by
EulerAnglesIndex.quaternionThe
Quaternionrepresentation of the Euler angles.rotation_matrixReturns the 3x3 rotation matrix representation of the Euler angles.
Inherited from
ArrayMixinarrayThe array representation of the geometric entity.
shapeReturn the shape of the array.
Public Methods:
from_array(array[, copy])Constructs a
EulerAnglesfrom a numpy array of shape (3,) representing, indexed byEulerAnglesIndex.from_rotation_matrix(rotation_matrix)Constructs a
EulerAnglesfrom a 3x3 rotation matrix.Inherited from
ArrayMixinfrom_array(array[, copy])Create an instance from a NumPy array.
from_list(values)Create an instance from a list of values.
tolist()Convert the array to a Python list.
to_list()Convert the array to a Python list.
copy()Return a copy of the object with a copied array.
- classmethod from_array(array, copy=True)[source]¶
Constructs a
EulerAnglesfrom a numpy array of shape (3,) representing, indexed byEulerAnglesIndex.- Parameters:
- Return type:
- Returns:
A
EulerAnglesinstance.
- classmethod from_rotation_matrix(rotation_matrix)[source]¶
Constructs a
EulerAnglesfrom a 3x3 rotation matrix.
- property array: ndarray[tuple[Any, ...], dtype[float64]]¶
Converts the EulerAngles instance to a numpy array of shape (3,), indexed by
EulerAnglesIndex.
- property quaternion: Quaternion¶
The
Quaternionrepresentation of the Euler angles.
- property rotation_matrix: ndarray[tuple[Any, ...], dtype[float64]]¶
Returns the 3x3 rotation matrix representation of the Euler angles.
- copy()¶
Return a copy of the object with a copied array.
- Return type:
ArrayMixin