diff options
| author | hybrid <hybrid@hybridlabs.pro> | 2026-07-12 21:30:48 +0300 |
|---|---|---|
| committer | hybrid <hybrid@hybridlabs.pro> | 2026-07-12 21:30:48 +0300 |
| commit | 4020a7124a80a608acd41a913ca5f6ad3ff3d488 (patch) | |
| tree | 53ecefe6279497a4d2c6a921cab6dade6ed85e40 /src | |
| parent | 866393b70f5baddcaf9571b7240ebd4ce44bc67c (diff) | |
| download | a3catragmx-4020a7124a80a608acd41a913ca5f6ad3ff3d488.tar.gz a3catragmx-4020a7124a80a608acd41a913ca5f6ad3ff3d488.tar.bz2 a3catragmx-4020a7124a80a608acd41a913ca5f6ad3ff3d488.zip | |
add: tmp commit
Diffstat (limited to 'src')
| -rw-r--r-- | src/atragmx.c | 14 | ||||
| -rw-r--r-- | src/ballistics.c | 31 |
2 files changed, 42 insertions, 3 deletions
diff --git a/src/atragmx.c b/src/atragmx.c index af68b2c..ff684c3 100644 --- a/src/atragmx.c +++ b/src/atragmx.c @@ -97,8 +97,7 @@ ATragMXSolution *ATragMXCalcSolution(ATragMXContext *ctx, ace_config *ace) { if (ace->ballistics->enabled) ctx->gun.ballistic_coef - = atmospheric_correction( - ctx->gun.ballistic_coef, + = atmospheric_correction(ctx->gun.ballistic_coef, ctx->atmosphere.temperature, ctx->atmosphere.barometric_pressure, ctx->atmosphere.relative_humidity, @@ -129,8 +128,17 @@ ATragMXSolution *ATragMXCalcSolution(ATragMXContext *ctx, ace_config *ace) { // calculate magnitude of bullet.velocity bullet.speed = hypot(bullet.velocity[0], hypot(bullet.velocity[1], bullet.velocity[2])); + memcpy(local_solution.true_velocity, + (double[3]){bullet.velocity[0] - wind1[0], + bullet.velocity[1] - wind1[1], + bullet.velocity[2] - wind1[2]}, + sizeof(local_solution.true_velocity)); + local_solution.true_speed = hypot(local_solution.true_velocity[0], + hypot(local_solution.true_velocity[1], + local_solution.true_velocity[2])); + + if (ace->ballistics->enabled) - } return sln; diff --git a/src/ballistics.c b/src/ballistics.c index 10d97da..418318a 100644 --- a/src/ballistics.c +++ b/src/ballistics.c @@ -4,6 +4,12 @@ #include "constants.h" #include "context.h" +static inline double speed_of_sound(double temperature); +static inline double calculate_retard(DragModel drag_function, + double ballistic_coefficient, + double velocity, + double mach); + double atmospheric_correction(double ballistic_coefficient, double temperature, double pressure, @@ -36,3 +42,28 @@ double calculate_air_density(double temperature, else return pressure / (SPECIFIC_GAST_CONSTANT_DRY_AIR * temperature); } + +static inline double speed_of_sound(double temperature) { + return sqrt(331.3 * (1.0 + temperature - 273.15 / 273.15)); +} + +static inline double +calculate_retard(DragModel ballistic_model, + double ballistic_coefficient, + double velocity, + double mach) +{ + double m = velocity / mach; +for (int i = 0 +} + +double retard(DragModel ballistic_model, + double ballistic_coefficient, + double velocity, + double temperature) +{ + return calculate_retard(ballistic_model, + ballistic_coefficient, + velocity, + speed_of_sound(temperature)); +} |
