Update the pi_2_pi function to a use of a modulo instead of two while.

This commit is contained in:
Alexis Paques
2018-07-10 09:22:18 +02:00
parent 39aa4f5a6a
commit b243750a13
17 changed files with 19 additions and 117 deletions

View File

@@ -18,13 +18,7 @@ class State:
def pi_2_pi(angle):
while(angle > math.pi):
angle = angle - 2.0 * math.pi
while(angle < -math.pi):
angle = angle + 2.0 * math.pi
return angle
return (angle + math.pi) % (2*math.pi) - math.pi
def update(state, v, delta, dt, L):