sponge.function.calc_angle_by_vectors
- sponge.function.calc_angle_by_vectors(vector1: Tensor, vector2: Tensor, keepdims: bool = False)[source]
Compute angle between two vectors. For vector \(\vec {v_1} = (x_1, x_2, x_3, ..., x_n)\) and \(\vec {v_2} = (y_1, y_2, y_3, ..., y_n)\) , the formula is
\[\theta = \arccos {\frac{|x_1y_1 + x_2y_2 + \cdots + x_ny_n|}{\sqrt{x_1^2 + x_2^2 + \cdots + x_n^2}\sqrt{y_1^2 + y_2^2 + \cdots + y_n^2}}}\]- Parameters
vector1 (Tensor) – Tensor of shape \((..., D)\). Data type is float. D means spatial dimension of the simulation system. Usually is 3. Vector of \(\vec{v_1}\).
vector2 (Tensor) – Tensor of shape \((..., D)\). Data type is float. Vector of \(\vec{v_2}\).
keepdims (bool) – If this is set to True, the last axis will be left in the result as dimensions with size one. Default:
False
.
- Returns
angle (Tensor), a tensor of shape \((...)\) or \((..., 1)\). Data type is float.
- Supported Platforms:
Ascend
GPU