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 | |
| parent | 866393b70f5baddcaf9571b7240ebd4ce44bc67c (diff) | |
| download | a3catragmx-4020a7124a80a608acd41a913ca5f6ad3ff3d488.tar.gz a3catragmx-4020a7124a80a608acd41a913ca5f6ad3ff3d488.tar.bz2 a3catragmx-4020a7124a80a608acd41a913ca5f6ad3ff3d488.zip | |
add: tmp commit
Diffstat (limited to '')
| -rw-r--r-- | include/ballistics.h | 5 | ||||
| -rw-r--r-- | include/context.h | 2 | ||||
| -rw-r--r-- | include/drag_model.h | 6 | ||||
| -rw-r--r-- | src/atragmx.c | 14 | ||||
| -rw-r--r-- | src/ballistics.c | 31 |
5 files changed, 54 insertions, 4 deletions
diff --git a/include/ballistics.h b/include/ballistics.h index 470c7a6..84a883d 100644 --- a/include/ballistics.h +++ b/include/ballistics.h @@ -13,4 +13,9 @@ double calculate_air_density(double temperature, double pressure, double relative_humidity); +double retard(DragModel ballistic_model, + double ballistic_coefficient, + double velocity, + double temperature); + #endif diff --git a/include/context.h b/include/context.h index a2f651f..65b4585 100644 --- a/include/context.h +++ b/include/context.h @@ -16,7 +16,7 @@ typedef enum { BC_G5, BC_G6, BC_G7, -} BallisticModel; +} DragModel; typedef enum { ICAO, diff --git a/include/drag_model.h b/include/drag_model.h new file mode 100644 index 0000000..baf5f72 --- /dev/null +++ b/include/drag_model.h @@ -0,0 +1,6 @@ +#ifndef DRAG_MODEL_H +#define DRAG_MODEL_H + + + +#endif 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)); +} |
