oneflow.atan2

oneflow.atan2()

Element-wise arctangent of input{i}/other{i} with consideration of the quadrant. Returns a new tensor with the signed angles in radians between vector (other{i},input{i}) and vector (1, 0).

The shapes of input and other must be broadcastable.

Parameters
  • input (Tensor) – the first input tensor.

  • other (Tensor) – the second input tensor.

For example:

>>> import oneflow as flow
>>> import numpy as np

>>> x1 = flow.Tensor(np.array([1,2,3]))
>>> y1 = flow.Tensor(np.array([3,2,1]))
>>> x2 = flow.Tensor(np.array([1.53123589,0.54242598,0.15117185]))
>>> y2 = flow.Tensor(np.array([-0.21906378,0.09467151,-0.75562878]))
>>> x3 = flow.Tensor(np.array([1,0,-1]))
>>> y3 = flow.Tensor(np.array([0,1,0]))

>>> flow.atan2(x1,y1).numpy()
array([0.32175055, 0.7853982 , 1.2490457 ], dtype=float32)
>>> flow.atan2(x2,y2).numpy()
array([1.7128955, 1.3980033, 2.9441385], dtype=float32)
>>> flow.atan2(x3,y3).numpy()
array([ 1.5707964,  0.       , -1.5707964], dtype=float32)