angles_between_list_of_vectors

halotools.utils.angles_between_list_of_vectors(v0, v1, tol=0.001)[source] [edit on github]

Calculate the angle between a collection of 3d vectors

Parameters:

v0 : ndarray

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

Note that the normalization of v0 will be ignored.

v1 : ndarray

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

Note that the normalization of v1 will be ignored.

tol : float, optional

Acceptable numerical error for errors in angle. This variable is only used to round off numerical noise that otherwise causes exceptions to be raised by the inverse cosine function. Default is 0.001.

Returns:

angles : ndarray

Numpy array of shape (npts, ) storing the angles between each pair of corresponding points in v0 and v1.

Returned values are in units of radians spanning [0, pi].

Examples

>>> npts = int(1e4)
>>> v0 = np.random.random((npts, 3))
>>> v1 = np.random.random((npts, 3))
>>> angles = angles_between_list_of_vectors(v0, v1)