rigid_body_motion.best_fit_rotation

rigid_body_motion.best_fit_rotation(v1, v2, dim=None, axis=None)[source]

Least-squares best-fit rotation between two arrays of vectors.

Finds the rotation r that minimizes:

\[|| v_2 - rot(r, v_1) ||\]
Parameters
v1: array_like, shape (…, 3, …)

The first array of vectors.

v2: array_like, shape (…, 3, …)

The second array of vectors.

dim: str, optional

If the first array is a DataArray, the name of the dimension representing the spatial coordinates of the vectors.

axis: int, optional

The axis of the arrays representing the spatial coordinates of the vectors. Defaults to the last axis of the arrays.

Returns
rotation: array_like, shape (4,)

Rotation of transform.

References

Adapted from https://github.com/ClayFlannigan/icp