angles_between_list_of_vectors¶

halotools.utils.
angles_between_list_of_vectors
(v0, v1, tol=0.001, vn=None)[source] [edit on github]¶ Calculate the angle between a collection of ndimensional vectors
Parameters:  v0 : ndarray
Numpy array of shape (npts, ndim) storing a collection of ndimD vectors Note that the normalization of
v0
will be ignored. v1 : ndarray
Numpy array of shape (npts, ndim) storing a collection of ndimD 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.
 n1 : ndarray
normal vector
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
Let’s create two sets of semirandom 3D unit vectors.
>>> npts = int(1e4) >>> ndim = 3 >>> v1 = np.random.random((npts, ndim)) >>> v2 = np.random.random((npts, ndim))
We then can find the angle between each pair of vectors in v1 and v2.
>>> angles = angles_between_list_of_vectors(v1, v2)