mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
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.
This commit is contained in:
@@ -28,6 +28,18 @@ namespace omath::projectile_prediction
|
|||||||
const float m_maximum_simulation_time;
|
const float m_maximum_simulation_time;
|
||||||
const float m_distance_tolerance;
|
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]]
|
[[nodiscard]]
|
||||||
std::optional<float>
|
std::optional<float>
|
||||||
maybe_calculate_projectile_launch_pitch_angle(const Projectile& projectile,
|
maybe_calculate_projectile_launch_pitch_angle(const Projectile& projectile,
|
||||||
|
|||||||
Reference in New Issue
Block a user