import numpy as np from math import acos, asin def process_angle(_angle): ret = _angle if ret < 0: ret += (abs(ret) // (2*np.pi) + 1) * 2*np.pi if ret >= 2 * np.pi: ret -= (abs(ret) // (2*np.pi)) * 2*np.pi assert 0 <= ret < 2 * np.pi, f'invalid angle: {ret}' assert abs(np.sin(ret) - np.sin(_angle) ) < 1e-5 and (np.cos(ret) - np.cos(_angle)) < 1e-5 return ret def asincos(sin_value, cos_value): if sin_value >= 0: # 第一象限和第二象限 return acos(cos_value) else: if cos_value >= 0: # 第四象限 return asin(sin_value) else: # 第三象限 return 2*np.pi - acos(cos_value)