angles_between_list_of_vectors¶
- halotools.utils.angles_between_list_of_vectors(v0, v1, tol=0.001, vn=None)[source]¶
Calculate the angle between a collection of n-dimensional vectors
- Parameters:
- v0ndarray
Numpy array of shape (npts, ndim) storing a collection of ndim-D vectors Note that the normalization of
v0
will be ignored.- v1ndarray
Numpy array of shape (npts, ndim) storing a collection of ndim-D vectors Note that the normalization of
v1
will be ignored.- tolfloat, 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.
- n1ndarray
normal vector
- Returns:
- anglesndarray
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 semi-random 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)