From bb27d4f1771ffe89066ee503f1407483ab0eb25f Mon Sep 17 00:00:00 2001 From: Sepehr Madani <ssepehrmadani@gmail.com> Date: Tue, 1 Sep 2020 00:21:00 -0400 Subject: [PATCH] Adds wrapToPi function for angles --- utils/converter.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/utils/converter.py b/utils/converter.py index 33bc2e1..f19d01f 100644 --- a/utils/converter.py +++ b/utils/converter.py @@ -1,5 +1,6 @@ from math import cos, acos, pi from numpy import arange +from cmath import exp, phase def deg_to_u(degrees): return [cos(x * pi / 180) for x in degrees] @@ -9,3 +10,11 @@ def range_in_deg(res): def u_to_deg(u): return [acos(x) * 180 / pi for x in u] + +def vectorWrapToPi(vector): + """Wraps a list of angles in the [-π, π] range.""" + return [wrapToPi(x) for x in vector] + +def wrapToPi(theta): + """Wraps an angle in the [-π, π] range.""" + return phase(exp(1j * theta)) \ No newline at end of file -- GitLab