Fit a proper rotation and translation between corresponding mesh vertices.
The facial basis builder uses this to perform a shape-edited rigid component
without allowing expression targets to scale, shear or reflect its geometry.
Inputs are flat XYZ buffers in the same units, and a nonempty, unique selection
indexes both. No input is mutated. Apply the returned rotation to a point minus
referenceCenter, then add targetCenter. Centered application avoids cancellation
between a large translation and a rotated absolute coordinate.
Horn's absolute-orientation method (JOSA A 4, 1987, pp. 629–642, section 4)
maximizes q^T N q for a unit quaternion. N is symmetric 4 by 4; its largest
eigenvector gives the least-squares proper rotation. Scale is fixed at one.
Cyclic Jacobi rotations diagonalize N to floating precision. Normalizing the
centered clouds before their products keeps covariance representable across
coordinate scales; normalizing covariance stabilizes the solve. Repeated
maximal eigenvalues have multiple optimal rotations; the fixed sweep and
first-maximum ordering select one deterministically. A collapsed covariance
selects identity and the centroid translation. This fit is geometric, and
establishes neither a physiological joint trajectory nor nonpenetration.
Fit a proper rotation and translation between corresponding mesh vertices. The facial basis builder uses this to perform a shape-edited rigid component without allowing expression targets to scale, shear or reflect its geometry. Inputs are flat XYZ buffers in the same units, and a nonempty, unique selection indexes both. No input is mutated. Apply the returned rotation to a point minus referenceCenter, then add targetCenter. Centered application avoids cancellation between a large translation and a rotated absolute coordinate.
Horn's absolute-orientation method (JOSA A 4, 1987, pp. 629–642, section 4) maximizes q^T N q for a unit quaternion. N is symmetric 4 by 4; its largest eigenvector gives the least-squares proper rotation. Scale is fixed at one. Cyclic Jacobi rotations diagonalize N to floating precision. Normalizing the centered clouds before their products keeps covariance representable across coordinate scales; normalizing covariance stabilizes the solve. Repeated maximal eigenvalues have multiple optimal rotations; the fixed sweep and first-maximum ordering select one deterministically. A collapsed covariance selects identity and the centroid translation. This fit is geometric, and establishes neither a physiological joint trajectory nor nonpenetration.