from_align_vectors#
- classmethod Quaternion.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]#
Initialize an estimated 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
other
andinitial
after alignment. Default isFalse
.- return_sensitivity
Whether to return the sensitivity matrix. Default is
False
.
- Returns:
estimated_quaternion
Best estimate of the quaternion that transforms
initial
toother
.rmsd
Returned when
return_rmsd=True
.sensitivity
Returned 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.]]