From 4b44ce06676bb4a55526b414d447a1b73e7d0950 Mon Sep 17 00:00:00 2001 From: Orange Date: Thu, 31 Jul 2025 21:51:52 +0300 Subject: [PATCH] Documents projectile launch angle formula Adds a comment documenting the formula used for calculating the projectile launch pitch angle. The comment includes a link to the Stack Overflow discussion where the formula was found and the LaTeX representation of the formula for clarity. --- .../proj_pred_engine_legacy.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/omath/projectile_prediction/proj_pred_engine_legacy.hpp b/include/omath/projectile_prediction/proj_pred_engine_legacy.hpp index 44eec14..8a72ee9 100644 --- a/include/omath/projectile_prediction/proj_pred_engine_legacy.hpp +++ b/include/omath/projectile_prediction/proj_pred_engine_legacy.hpp @@ -28,6 +28,18 @@ namespace omath::projectile_prediction const float m_maximum_simulation_time; const float m_distance_tolerance; + // Realization of this formula: + // https://stackoverflow.com/questions/54917375/how-to-calculate-the-angle-to-shoot-a-bullet-in-order-to-hit-a-moving-target + /* + \[ + \theta \;=\; \arctan\!\Biggl( + \frac{% + v^{2}\;\pm\;\sqrt{\,v^{4}-g\!\left(gx^{2}+2yv^{2}\right)\,} + }{% + gx + }\Biggr) + \] + */ [[nodiscard]] std::optional maybe_calculate_projectile_launch_pitch_angle(const Projectile& projectile,