Python/ Numpy 如何在区间 0, pi/2 上使用 arctan 或 arctan2?

Python/ Numpy How to use arctan or arctan2 on the interval 0, pi/2?

是否可以使用 arctan 或 arctan2 numpy 函数,结果总是在第一象限 (0,pi/2)? 谢谢

如果要计算 x 轴与线段连接点 (0, 0) 和 (x) 之间的最小 "deviation" 角度(在 [0,pi/2] 区间内) , y), 你可以使用:

phi = numpy.arctan2(y, x)
phi = min(abs(phi), math.pi - abs(phi))

或:

phi = numpy.arctan2(abs(y), abs(x))