snippet: correct formula for calculating angle to horizon

This commit is contained in:
Oleg Kalachev
2018-09-12 23:35:53 +03:00
parent ed51b826a0
commit 8aeb11f771

View File

@@ -86,12 +86,14 @@ flipped = not -pi_2 <= telem.pitch <= pi_2 or not -pi_2 <= telem.roll <= pi_2
Рассчет общего угла коптера к горизонту:
TODO: fix
```python
pi_2 = math.pi / 2
telem = get_telemetry()
flipped = not -pi_2 <= telem.pitch <= pi_2 or not -pi_2 <= telem.roll <= pi_2
angle_to_horizon = math.atan(math.hypot(math.tan(telem.pitch), math.tan(telem.roll)))
if flipped:
angle_to_horizon = math.pi - angle_to_horizon
```
---