如何将弧度角x
的值从区间[[] -infinite,infinite [转换为区间[[[-pi,pi]?]
45度=> 45度
import numpy as np
np.arctan2(np.sin(x), np.cos(x)) # converts x to [-np.pi, np.pi]
...和:
np.arctan2(np.sin(x), np.cos(x)) + np.pi # converts x to [0, 2*np.pi]
from math import pi
x = 8.14
bounded_x = x % (2*pi)
bounded_x
1.8568146928204143
并且您可以简单地减去pi来将边界从-pi移到pi
bounded_x = pi - (x % (2*pi))
bounded_x
1.2847779607693788