rotate_vector_collection

halotools.utils.rotate_vector_collection(rotation_matrices, vectors, optimize=False)[source] [edit on github]

Given a collection of rotation matrices and a collection of 3d vectors, apply each matrix to rotate the corresponding vector.

Parameters:

rotation_matrices : ndarray

Numpy array of shape (npts, 3, 3) storing a collection of rotation matrices

vectors : ndarray

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

Returns:

rotated_vectors : ndarray

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

Examples

In this example, we’ll randomly generate two sets of unit-vectors, v0 and v1. We’ll use the rotation_matrices_from_vectors function to generate the rotation matrices that rotate each v0 into the corresponding v1. Then we’ll use the rotate_vector_collection function to apply each rotation, and verify that we recover each of the v1.

>>> npts = int(1e4)
>>> v0 = normalized_vectors(np.random.random((npts, 3)))
>>> v1 = normalized_vectors(np.random.random((npts, 3)))
>>> rotation_matrices = rotation_matrices_from_vectors(v0, v1)
>>> v2 = rotate_vector_collection(rotation_matrices, v0)
>>> assert np.allclose(v1, v2)