from_align_vectors#
- classmethod Rotation.from_align_vectors(other: Union[Vector3d, tuple, list], initial: Union[Vector3d, tuple, list], weights: Optional[ndarray] = None, return_rmsd: bool = False, return_sensitivity: bool = False) Union[Quaternion, Tuple[Quaternion, float], Tuple[Quaternion, ndarray], Tuple[Quaternion, float, ndarray]][source]#
Return an estimated rotation 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_rotationBest estimate of the rotation that transforms
initialtoother.rmsdReturned when
return_rmsd=True.sensitivityReturned when
return_sensitivity=True.
Examples
>>> from orix.quaternion import Rotation >>> from orix.vector import Vector3d >>> v1 = Vector3d([[1, 0, 0], [0, 1, 0]]) >>> v2 = Vector3d([[0, -1, 0], [0, 0, 1]]) >>> r12 = Rotation.from_align_vectors(v2, v1) >>> r12 * v1 Vector3d (2,) [[ 0. -1. 0.] [ 0. 0. 1.]] >>> r21, dist = Rotation.from_align_vectors(v1, v2, return_rmsd=True) >>> dist 0.0 >>> r21 * v2 Vector3d (2,) [[1. 0. 0.] [0. 1. 0.]]