Rotation#

class orix.quaternion.Rotation(data: )[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

 Rotation.a Return or set the scalar quaternion component. Rotation.angle Return the angle of rotation $$\omega = 2\arccos{|a|}$$. Rotation.antipodal Return the rotation and its antipodal. Rotation.axis Return the axis of rotation $$\hat{\mathbf{n}} = (b, c, d)$$. Rotation.b Return or set the first vector quaternion component. Rotation.c Return or set the second vector quaternion component. Rotation.conj Return the conjugate of the quaternion $$Q^* = a - bi - cj - dk$$. Rotation.d Return or set the third vector quaternion component. Rotation.data Return the data. Rotation.improper Return True for improper rotations and False otherwise. Rotation.ndim Return the number of navigation dimensions of the object. Rotation.norm Return the norm of the data. Rotation.shape Return the shape of the object. Rotation.size Return the total number of entries in this object. Rotation.unit 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)$$ . Rotation.from_euler(euler[, direction, degrees]) Create unit quaternions from Euler angle sets . Create unit quaternions from homochoric vectors $$\mathbf{h}$$ . Rotation.from_matrix(matrix) Create unit quaternions from orientation matrices . 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}$$ . 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 . Rotation.to_euler([degrees]) Return the unit quaternions as Euler angles in the Bunge convention . Return the unit quaternions as homochoric vectors . Return the unit quaternions as orientation matrices . 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

Misorientation from aligning directions

Rotating z-vector to high-symmetry crystal directions

Rotating z-vector to high-symmetry crystal directions

Rotations mapping the fundamental sector on S2

Rotations mapping the fundamental sector on S2

Combining rotations

Combining rotations