rotation_matrices_from_angles

halotools.utils.rotation_matrices_from_angles(angles, directions)[source] [edit on github]

Calculate a collection of rotation matrices defined by an input collection of rotation angles and rotation axes.

Parameters:

angles : ndarray

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

directions : ndarray

Numpy array of shape (npts, 3) storing a collection of rotation axes in 3d

Returns:

matrices : ndarray

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

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)
>>> angles = np.random.uniform(-np.pi/2., np.pi/2., npts)
>>> directions = np.random.random((npts, 3))
>>> rotation_matrices = rotation_matrices_from_angles(angles, directions)