Rotation#
- class orix.quaternion.Rotation(data: ndarray | Rotation | list | tuple)[source]#
Bases:
Quaternion
Rotations of coordinate systems, leaving objects in place.
Rotations \(R\) can be parametrized in numerous ways, but in orix are handled as unit quaternions. Rotations can act on vectors or other rotations. They are often most easily visualized as being a turn of a certain angle \(\omega\) about a certain axis \(\hat{\mathbf{n}}\).
This rotation class add a sense of proper or improper rotations to
Quaternion
. An improper rotation in orix operates on vectors as a rotation by the unit quaternion followed by inversion.See the documentation of quaternions for the applied conventions.
Examples
Rotate vector vA defined in coordinate system A to vector vB defined in coordinate system B
>>> import numpy as np >>> from orix.quaternion import Quaternion >>> from orix.vector import Vector3d >>> R = Rotation.random() >>> vA = Vector3d.random() >>> vB = R * vA >>> np.allclose(vB.data, np.dot(R.to_matrix().squeeze(), vA.data.squeeze())) True
Combine two rotations R1 and R2, applied in that order
>>> R1, R2 = Rotation.random(2) >>> R12 = R2 * R1 >>> np.allclose( ... R12.to_matrix().squeeze(), ... np.dot(R2.to_matrix().squeeze(), R1.to_matrix().squeeze()) ... ) True
Attributes
Return or set the scalar quaternion component.
Return the angle of rotation \(\omega = 2\arccos{|a|}\).
Return the rotation and its antipodal.
Return the axis of rotation \(\hat{\mathbf{n}} = (b, c, d)\).
Return or set the first vector quaternion component.
Return or set the second vector quaternion component.
Return the conjugate of the quaternion \(Q^* = a - bi - cj - dk\).
Return or set the third vector quaternion component.
Return the data.
Return
True
for improper rotations andFalse
otherwise.Return the number of navigation dimensions of the object.
Return the norm of the data.
Return the shape of the object.
Return the total number of entries in this object.
Return the unit object.
Methods
Rotation.angle_with
(other[, degrees])Return the angles of rotation transforming the rotations to the other rotations.
Rotation.angle_with_outer
(other[, degrees])Return the angles of rotation transforming the rotations to all the other rotations.
Rotation.dot
(other)Return the dot products of the quaternions and the other quaternions.
Rotation.dot_outer
(other)Return the outer dot products of the rotations and the other rotations.
Return an empty object with the appropriate dimensions.
Return a new rotation instance collapsed into one dimension.
Rotation.from_align_vectors
(other, initial)Estimate a quaternion to optimally align two sets of vectors.
Rotation.from_axes_angles
(axes, angles[, ...])Create unit quaternions from axis-angle pairs \((\hat{\mathbf{n}}, \omega)\) [Rowenhorst et al., 2015].
Rotation.from_euler
(euler[, direction, degrees])Create unit quaternions from Euler angle sets [Rowenhorst et al., 2015].
Create unit quaternions from homochoric vectors \(\mathbf{h}\) [Rowenhorst et al., 2015].
Rotation.from_matrix
(matrix)Create unit quaternions from orientation matrices [Rowenhorst et al., 2015].
Rotation.from_neo_euler
(neo_euler)[Deprecated] Create unit quaternion(s) from a neo-euler (vector) representation.
Rotation.from_rodrigues
(ro[, angles])Create unit quaternions from three-component Rodrigues vectors \(\hat{\mathbf{n}}\) or four-component Rodrigues-Frank vectors \(\mathbf{\rho}\) [Rowenhorst et al., 2015].
Rotation.from_scipy_rotation
(rotation)Create unit quaternions from
scipy.spatial.transform.Rotation
.Rotation.get_random_sample
([size, replace, ...])Return a new flattened object from a random sample of a given size.
Rotation.identity
([shape])Create identity quaternions.
Return the inverse rotations \(R^{-1}\).
Return the mean quaternion with unitary weights.
Rotation.outer
(other[, lazy, chunk_size, ...])Return the outer rotation products of the rotations and the other rotations or vectors.
Rotation.random
([shape])Create object with random data.
Rotation.random_vonmises
([shape, alpha, ...])Return random rotations with a simplified Von Mises-Fisher distribution.
Rotation.reshape
(*shape)Return a new object with the same data in a new shape.
Return a new object with the same data with length 1-dimensions removed.
Rotation.stack
(sequence)Return a stacked object from the sequence.
Return the unit quaternions as axis-angle vectors [Rowenhorst et al., 2015].
Rotation.to_euler
([degrees])Return the unit quaternions as Euler angles in the Bunge convention [Rowenhorst et al., 2015].
Return the unit quaternions as homochoric vectors [Rowenhorst et al., 2015].
Return the unit quaternions as orientation matrices [Rowenhorst et al., 2015].
Rotation.to_rodrigues
([frank])Return the unit quaternions as Rodrigues or Rodrigues-Frank
Rotation.transpose
(*axes)Return a new object with the same data transposed.
Rotation.triple_cross
(q1, q2, q3)Pointwise cross product of three quaternions.
Rotation.unique
([return_index, ...])Return the unique rotations from these rotations.
Examples using Rotation
#
Misorientation from aligning directions
Rotating z-vector to high-symmetry crystal directions
Rotations mapping the fundamental sector on S2