sponge.function.calc_angle_by_vectors

View Source On Gitee
sponge.function.calc_angle_by_vectors(vector1: Tensor, vector2: Tensor, keepdims: bool = False)[source]

Compute angle between two vectors. For vector v1=(x1,x2,x3,...,xn) and v2=(y1,y2,y3,...,yn) , the formula is

θ=arccos|x1y1+x2y2++xnyn|x12+x22++xn2y12+y22++yn2
Parameters
  • vector1 (Tensor) – Tensor of shape (...,D). Data type is float. D means spatial dimension of the simulation system. Usually is 3. Vector of v1.

  • vector2 (Tensor) – Tensor of shape (...,D). Data type is float. Vector of v2.

  • 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