Quaternion#
- class orix.quaternion.Quaternion(data=None)[source]#
Bases:
Object3d
Basic quaternion object.
- Quaternions support the following mathematical operations:
Unary negation.
Inversion.
Multiplication with other quaternions and vectors.
Quaternion-quaternion multiplication for two quaternions \(q_1 = (a_1, b_1, c_1, d_1)\) and \(q_2 = (a_2, b_2, c_2, d_2)\) with \(q_3 = (a_3, b_3, c_3, d_3) = q_1 \cdot q_2\) follows as:
\[ \begin{align}\begin{aligned}a_3 = (a_1 \cdot a_2 - b_1 \cdot b_2 - c_1 \cdot c_2 - d_1 \cdot d_2)\\b_3 = (a_1 \cdot b_2 + b_1 \cdot a_2 + c_1 \cdot d_2 - d_1 \cdot c_2)\\c_3 = (a_1 \cdot c_2 - b_1 \cdot d_2 + c_1 \cdot a_2 + d_1 \cdot b_2)\\d_3 = (a_1 \cdot d_2 + b_1 \cdot c_2 - c_1 \cdot b_2 + d_1 \cdot a_2)\end{aligned}\end{align} \]Quaternion-vector multiplication with a three-dimensional vector \(v = (x, y, z)\) calculates a rotated vector \(v' = q \cdot v \cdot q^{-1}\) and follows as:
\[ \begin{align}\begin{aligned}v'_x = x(a^2 + b^2 - c^2 - d^2) + 2(z(a \cdot c + b \cdot d) + y(b \cdot c - a \cdot d))\\v'_y = y(a^2 - b^2 + c^2 - d^2) + 2(x(a \cdot d + b \cdot c) + z(c \cdot d - a \cdot b))\\v'_z = z(a^2 - b^2 - c^2 + d^2) + 2(y(a \cdot b + c \cdot d) + x(b \cdot d - a \cdot c))\end{aligned}\end{align} \]Attributes
Return or set the scalar quaternion component.
Return the quaternions and the antipodal ones.
Return or set the first vector quaternion component.
Return or set the second vector quaternion component.
Return the conjugate of this quaternion \(q^* = a - bi - cj - dk\).
Return or set the third vector quaternion component.
Quaternion.dim
Return the number of dimensions for this object.
Methods
Quaternion.dot
(other)Return the dot products of the quaternions and the other quaternions.
Quaternion.dot_outer
(other)Return the dot products of all quaternions to all the other quaternions.
Quaternion.from_align_vectors
(other, initial)Initialize an estimated quaternion to optimally align two sets of vectors.
Quaternion.from_axes_angles
(axes, angles[, ...])Initialize from axis-angle pair(s).
Quaternion.from_euler
(euler[, direction, ...])Initialize from Euler angle set(s) [Rowenhorst et al., 2015].
Quaternion.from_matrix
(matrix)Create unit quaternions from the orientation matrices [Rowenhorst et al., 2015].
Quaternion.from_neo_euler
(neo_euler)Create unit quaternion(s) from a neo-euler (vector) representation.
Quaternion.from_scipy_rotation
(rotation)Initialize from
scipy.spatial.transform.Rotation
.Quaternion.identity
([shape])Return identity quaternions.
Return the mean quaternion with unitary weights.
Quaternion.outer
(other[, lazy, chunk_size, ...])Return the outer products of the quaternions and the other quaternions or vectors.
Quaternion.random
([shape])Return random quaternions.
Quaternion.to_euler
([degrees])Return the normalized quaternions as Euler angles in the Bunge convention [Rowenhorst et al., 2015].
Return the normalized quaternions as orientation matrices [Rowenhorst et al., 2015].
Quaternion.triple_cross
(q1, q2, q3)Pointwise cross product of three quaternions.