Quaternion#
- class ansys.aedt.core.generic.quaternion.Quaternion(a=0, b=0, c=0, d=0)#
Implements fundamental quaternion operations.
Quaternions are created using
Quaternion(a, b, c, d)
.Quaternions are only used to represent rotations in 3D space. They are not used to represent translations or other transformations. Only methods related to rotations are implemented.
The quaternion is defined as: .. math:
q = a + bi + cj + dk
where
a
is the scalar part andb
,c
, andd
are the vector parts.This updated class offers enhanced functionality compared to the previous implementation, supporting both intrinsic and extrinsic rotations. Note that AEDT coordinate systems use intrinsic rotation.
References
[1] https://en.wikipedia.org/wiki/Quaternion [2] https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles [3] https://www.euclideanspace.com/maths/geometry/rotations/conversions/
Methods
Quaternion.add
(other)Adds another quaternion or compatible value to this quaternion.
Quaternion.axis_to_rotation_matrix
(x_axis, ...)Construct a rotation matrix from three orthonormal axes.
Returns the coefficients of the quaternion as a tuple.
Returns the conjugate of the quaternion.
Quaternion.div
(other)Performs quaternion division with another quaternion or compatible value.
Quaternion.from_axis_angle
(axis, angle)Creates a normalized rotation quaternion from a given axis and rotation angle.
Quaternion.from_euler
(angles, sequence[, ...])Creates a normalized rotation quaternion from the Euler angles using the specified rotation sequence.
Quaternion.from_rotation_matrix
(rotation_matrix)Converts a 3x3 rotation matrix to a quaternion.
Quaternion.hamilton_prod
(q1, q2)Evaluate the Hamilton product of two quaternions,
q1
andq2
, defined as:Returns the inverse of the quaternion.
Evaluate the inverse rotation of a vector that is defined by a quaternion.
Quaternion.mul
(other)Performs quaternion multiplication with another quaternion or compatible value.
Returns the norm of the quaternion.
Returns the normalized form of the quaternion.
Evaluate the rotation of a vector, defined by a quaternion.
Convert a rotation matrix to the corresponding axis of rotation. Parameters ---------- rotation_matrix : tuple of tuples or list of lists A 3x3 rotation matrix defined as a tuple of tuples or a list of lists. The matrix should be orthogonal. Returns ------- tuple The X, Y, and Z axes of the rotated frame. Examples -------- >>> from ansys.aedt.core.generic.quaternion import Quaternion >>> rotation_matrix = ( ... (0.7071067811865476, 0.0, 0.7071067811865476), ... (0.0, 1.0, 0.0), ... (-0.7071067811865476, 0.0, 0.7071067811865476), ... ) >>> x, y, z = Quaternion.rotation_matrix_to_axis(rotation_matrix) >>> x (0.7071067811865476, 0.0, -0.7071067811865476) >>> y (0.0, 1.0, 0.0) >>> z (-0.7071067811865476, 0.0, 0.7071067811865476).
Convert a quaternion to the axis angle rotation formulation.
Quaternion.to_euler
(sequence[, extrinsic])Converts the quaternion to Euler angles using the specified rotation sequence.
Returns the rotation matrix corresponding to the quaternion.
Attributes