updated incorrect angle normalization.

This commit is contained in:
Fabian
2021-03-22 15:25:22 +01:00
parent b7b5af03ba
commit 89439f7532
2 changed files with 10 additions and 8 deletions
+7 -6
View File
@@ -11,10 +11,11 @@ def angle_normalize(x, type="deg"):
Returns:
"""
if type not in ["deg", "rad"]: raise ValueError(f"Invalid type {type}. Choose one of 'deg' or 'rad'.")
if type == "deg":
return ((x + np.pi) % (2 * np.pi)) - np.pi
elif type == "rad":
two_pi = 2 * np.pi
return x - two_pi * np.floor((x + np.pi) / two_pi)
else:
raise ValueError(f"Invalid type {type}. Choose on of 'deg' or 'rad'.")
x = np.deg2rad(x) # x * pi / 180
two_pi = 2 * np.pi
return x - two_pi * np.floor((x + np.pi) / two_pi)