From 4ade826dd7d5eb79b82567ebe6e6bf2eeab02792 Mon Sep 17 00:00:00 2001 From: kaushalSawariya Date: Sun, 17 Aug 2025 15:50:42 +0530 Subject: [PATCH 1/2] Added constexpr GRAVITY constant (9.80665) as per guidelines --- physics/ground_to_ground_projectile_motion.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/physics/ground_to_ground_projectile_motion.cpp b/physics/ground_to_ground_projectile_motion.cpp index af362c524a4..803df1d2004 100644 --- a/physics/ground_to_ground_projectile_motion.cpp +++ b/physics/ground_to_ground_projectile_motion.cpp @@ -18,6 +18,11 @@ * @namespace physics * @brief Physics algorithms */ + +// Define gravity as a constant within guidelines +constexpr double GRAVITY = 9.80665; // Standard gravity (m/s^2) + + namespace physics { /** * @namespace ground_to_ground_projectile_motion @@ -44,7 +49,7 @@ double degrees_to_radians(double degrees){ * @returns The time that the projectile is in the air for */ template -T time_of_flight(T initial_velocity, T angle, double gravity = 9.81) { +T time_of_flight(T initial_velocity, T angle, double gravity = GRAVITY) { double Viy = initial_velocity * (std::sin(degrees_to_radians(angle))); // calculate y component of the initial velocity return 2.0 * Viy / gravity; } @@ -69,7 +74,7 @@ T horizontal_range(T initial_velocity, T angle, T time) { * @returns The max height that the projectile reaches */ template -T max_height(T initial_velocity, T angle, double gravity = 9.81) { +T max_height(T initial_velocity, T angle, double gravity = GRAVITY) { double Viy = initial_velocity * (std::sin(degrees_to_radians(angle))); // calculate y component of the initial velocity return (std::pow(Viy, 2) / (2.0 * gravity)); } From 2502f611781d8d830381cf3dbe510e387afc64df Mon Sep 17 00:00:00 2001 From: kaushal sawariya Date: Mon, 18 Aug 2025 11:03:36 +0530 Subject: [PATCH 2/2] Update physics/ground_to_ground_projectile_motion.cpp Co-authored-by: realstealthninja <68815218+realstealthninja@users.noreply.github.com> --- physics/ground_to_ground_projectile_motion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/physics/ground_to_ground_projectile_motion.cpp b/physics/ground_to_ground_projectile_motion.cpp index 803df1d2004..268557db274 100644 --- a/physics/ground_to_ground_projectile_motion.cpp +++ b/physics/ground_to_ground_projectile_motion.cpp @@ -20,7 +20,7 @@ */ // Define gravity as a constant within guidelines -constexpr double GRAVITY = 9.80665; // Standard gravity (m/s^2) +constexpr double GRAVITY = 9.80665; ///< Standard gravity (m/s^2) namespace physics {