rotation_matrices_from_vectors

halotools.utils.rotation_matrices_from_vectors(v0, v1)[source] [edit on github]

Calculate a collection of rotation matrices defined by the unique transformation rotating v1 into v2 about the mutually perpendicular axis.

Parameters:

v0 : ndarray

Numpy array of shape (npts, 3) storing a collection of initial vector orientations.

Note that the normalization of v0 will be ignored.

v1 : ndarray

Numpy array of shape (npts, 3) storing a collection of final vectors.

Note that the normalization of v1 will be ignored.

Returns:

matrices : ndarray

Numpy array of shape (npts, 3, 3) rotating each v0 into the corresponding v1

Notes

The function rotate_vector_collection can be used to efficiently apply the returned collection of matrices to a collection of 3d vectors

Examples

>>> npts = int(1e4)
>>> v0 = np.random.random((npts, 3))
>>> v1 = np.random.random((npts, 3))
>>> rotation_matrices = rotation_matrices_from_vectors(v0, v1)