diff options
author | Baitinq <you@example.com> | 2022-02-10 23:05:22 +0000 |
---|---|---|
committer | Baitinq <you@example.com> | 2022-02-10 23:11:07 +0000 |
commit | 137ab90edd7f9b6f91c0f7a0370912bf9fba49e8 (patch) | |
tree | fe9f7380720e944a2c2e8f65a9b0d1ddb3124843 /simulation.py | |
parent | Create initial README (diff) | |
download | OSLS-137ab90edd7f9b6f91c0f7a0370912bf9fba49e8.tar.gz OSLS-137ab90edd7f9b6f91c0f7a0370912bf9fba49e8.tar.bz2 OSLS-137ab90edd7f9b6f91c0f7a0370912bf9fba49e8.zip |
Fixed heading calculation by using atan2
Diffstat (limited to 'simulation.py')
-rw-r--r-- | simulation.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/simulation.py b/simulation.py index 70ea171..46a7c57 100644 --- a/simulation.py +++ b/simulation.py @@ -93,14 +93,14 @@ class Simulation(): print("Speed x: " + str(self.speed_x)) print("Speed y: " + str(self.speed_y)) - #TODO: HEADING behaves a bit weird, just a bit and it goes forever and hard to cancel. WELL CALCULATED OR IMPLEMENTED? - #speedx / speedy - #1 = 45 - #-1 = -45 - #0 = 90 - self.heading = math.degrees(self.speed_x / self.speed_y) #TODO? con speed, y luego heading influences thrust (gimbal), so pass as a parameter to func + #TODO: WELL CALCULATED? (angle well?) + ref_vec = (0, 1) + acc_vec = (self.speed_x, self.speed_y) + dot = (acc_vec[0] * ref_vec[0]) + (acc_vec[1] * ref_vec[1]) + det = (acc_vec[0] * ref_vec[1]) - (acc_vec[1] * ref_vec[0]) + self.heading = math.degrees(math.atan2(det, dot)) print("Heading: " + str(self.heading)) - + #update position based on velocity and delta self.x += self.speed_x * delta |