tfep.utils.geometry.vector_vector_angle

tfep.utils.geometry.vector_vector_angle(x1, x2)[source]

Return the angle in radians between a two vectors.

If both x1 and x2 have multiple vectors, the angles are computed in a batchwise fashion.

Parameters:
  • x1 (torch.Tensor) – A tensor of shape (*, D), where D is the vector dimensionality.

  • x2 (torch.Tensor) – A tensor of shape (*, D), where D is the vector dimensionality.

Returns:

angles – A tensor of shape (*,). As an example, if both inputs have shape (batch_size, D), then angles has shape (batch_size,) and angles[i] is the angle between vectors x1[i] and x2[i].

The angle is from 0 to pi.

Return type:

torch.Tensor