e15190.utilities.geometry.angle_between¶
- e15190.utilities.geometry.angle_between(v1, v2, directional=False, zero_vector=None)¶
Compute the angle between vectors.
- Parameters
v1 (1D array-like or 2D numpy array of shape (n_vectors, n_dim)) – The first vector or vectors. The dimension of vectors must be consistent with
v2. Ifv1is a 2D numpy array, the length must also be consistent with the length ofv2.v2 (1D array-like or 2D numpy array of shape (n_vectors, n_dim)) – The second vector or vectors. The dimension of vectors must be consistent with
v1. Ifv2is a 2D numpy array, the length must also be consistent with the length ofv1.directional (bool) – Whether to return the directional angle. Only support for vectors of two-dimension, otherwise it will be ignored. If True, the angle will be in the range \((-\pi, \pi]\). If False, the angle will be in the range \([0, \pi]\).
zero_vector (None, 'raise' or scalar) – To specify what to do when
v1orv2contains zero vectors, i.e. vectors with zero norms. If None, nothing will be done. Whatever warnings or errors show up during the calculation will be shown unless otherwise being suppressed. If ‘raise’, aRunTimeErrorwill be raised. If a scalar, the value will be assigned as the angle. The last option is sometimes useful for later identifying zero vectors.
- Returns
angles – The angle(s) between the two vectors in radians.
- Return type
float or 1D array-like