Skip to main content

Module alignment

Module alignment 

Source
Expand description

Fitting rotations to data, following scipy.spatial: the rotation that best aligns two sets of vectors (Rotation.align_vectors, the Kabsch or Wahba problem), the mean of rotations (Rotation.mean), orthogonal Procrustes analysis (procrustes, orthogonal_procrustes), and interpolation along great circles (geometric_slerp).

See the book entry Rotation fitting, Procrustes analysis and Hausdorff distance.

Structs§

Alignment
The result of align_vectors.
ProcrustesResult
The result of procrustes.

Functions§

align_vectors
The rotation C minimising Σ wᵢ ‖aᵢ − C bᵢ‖² (SciPy’s Rotation.align_vectors; Wahba’s problem). With B = Σ wᵢ aᵢ bᵢᵀ = U S Vᵀ, the answer is C = U diag(1, 1, det(UVᵀ)) Vᵀ (Kabsch’s algorithm); the determinant correction keeps it a rotation rather than a reflection. With a single pair, or one infinite weight, that pair (the primary) is aligned exactly by the smallest rotation, and the remaining freedom — a rotation about the primary — best aligns the others.
geometric_slerp
Points along the great circle from start to end on the unit sphere in any dimension, at the fractions t of the way (SciPy’s geometric_slerp): (sin((1 − t)ω) start + sin(tω) end) / sin ω, ω the angle between them. Both must be unit vectors; antipodal points have no unique great circle and are an error, and equal points give that point.
orthogonal_procrustes
The orthogonal matrix R minimising ‖A R − B‖_F and the scale Σ σᵢ (SciPy’s orthogonal_procrustes): with AᵀB = U S Vᵀ, R = U Vᵀ. A and B are m × d (rows are points); reflections are allowed.
procrustes
Procrustes analysis of two configurations of m points in d dimensions (SciPy’s scipy.spatial.procrustes): both are centred and scaled to unit norm, then the second is rotated (reflections allowed) and scaled to best match the first; the disparity is the remaining sum of squared differences, a measure of difference in shape.
rotation_mean
The mean of rotations (SciPy’s Rotation.mean): the unit quaternion maximising Σ wᵢ (q · qᵢ)², the eigenvector of the largest eigenvalue of Σ wᵢ qᵢ qᵢᵀ (Markley et al.). It minimises the weighted sum of squared chordal distances ‖R − Rᵢ‖², and is unaffected by the sign ambiguity q ~ −q.