geoana.spatial.rotation_matrix_from_normals#

geoana.spatial.rotation_matrix_from_normals(v0, v1, tol=1e-20, as_matrix=True)#

Generate a 3x3 rotation matrix defining the rotation from vector v0 to v1.

This function builds a quaternion representing the rotation, then constructs the rotation matrix.

\[\mathbf{Av_0} = \mathbf{v_1}\]
Parameters:
v0(3) numpy.ndarray

Starting orientation direction

v1(3) numpy.ndarray

Finishing orientation direction

tolfloat, optional

Numerical tolerance. If the length of the rotation axis is below this value, it is assumed to be no rotation, and an identity matrix is returned.

as_matrixbool, optional

If True, a (3,3) numpy.ndarray is returned. If False, the respective scipy.spatial.transform.Rotation object is returned.

Returns:
(3, 3) numpy.ndarray or scipy.spatial.transform.Rotation

The rotation matrix from v0 to v1, whose type depends on the as_matrix parameter.