from_align_vectors#
- classmethod Quaternion.from_align_vectors(other: Vector3d | tuple | list, initial: Vector3d | tuple | list, weights: ndarray | None = None, return_rmsd: bool = False, return_sensitivity: bool = False) Quaternion | tuple[Quaternion, float] | tuple[Quaternion, ndarray] | tuple[Quaternion, float, ndarray][source]#
Estimate a quaternion to optimally align two sets of vectors.
This method wraps
align_vectors(). See that method for further explanations of parameters and returns.- Parameters:
- other
Vectors of shape
(n,)in the other reference frame.- initial
Vectors of shape
(n,)in the initial reference frame.- weights
Relative importance of the different vectors.
- return_rmsd
Whether to return the (weighted) root mean square distance between
otherandinitialafter alignment. Default isFalse.- return_sensitivity
Whether to return the sensitivity matrix. Default is
False.
- Returns:
estimated_quaternionBest estimate of the quaternion that transforms
initialtoother.rmsdReturned when
return_rmsd=True.sensitivityReturned when
return_sensitivity=True.
Examples
>>> from orix.quaternion import Quaternion >>> from orix.vector import Vector3d >>> v1 = Vector3d([[1, 0, 0], [0, 1, 0]]) >>> v2 = Vector3d([[0, -1, 0], [0, 0, 1]]) >>> Q12 = Quaternion.from_align_vectors(v2, v1) >>> Q12 * v1 Vector3d (2,) [[ 0. -1. 0.] [ 0. 0. 1.]] >>> Q21, dist = Quaternion.from_align_vectors(v1, v2, return_rmsd=True) >>> dist 0.0 >>> Q21 * v2 Vector3d (2,) [[1. 0. 0.] [0. 1. 0.]]
Examples using Quaternion.from_align_vectors#
Rotating z-vector to high-symmetry crystal directions
Rotating z-vector to high-symmetry crystal directions