diff options
| author | hybrid <hybrid@hybridlabs.cc> | 2026-08-21 17:28:02 +0300 |
|---|---|---|
| committer | hybrid <hybrid@hybridlabs.cc> | 2026-08-21 17:28:02 +0300 |
| commit | ca33e8422977a35fd01558e82748dc203b42c1dd (patch) | |
| tree | 0bedf0fc6ba93a7b58fee6c60b1a47895dde9445 /src/atragmx.c | |
| parent | 7ad9c60cdb981d51756755dca4603e77611a0f61 (diff) | |
| download | a3catragmx-ca33e8422977a35fd01558e82748dc203b42c1dd.tar.gz a3catragmx-ca33e8422977a35fd01558e82748dc203b42c1dd.tar.bz2 a3catragmx-ca33e8422977a35fd01558e82748dc203b42c1dd.zip | |
Diffstat (limited to 'src/atragmx.c')
| -rw-r--r-- | src/atragmx.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/atragmx.c b/src/atragmx.c index 1b39dbc..7f5ff6d 100644 --- a/src/atragmx.c +++ b/src/atragmx.c @@ -3,10 +3,13 @@ #include <math.h> #include <string.h> +#include <assert.h> + #include "ballistics.h" #include "constants.h" #include "atragmx.h" #include "ace.h" +#include "context.h" #include "vector.h" #include "misc.h" @@ -76,6 +79,7 @@ ATragMXSolution *ATragMXCalcSolution(ATragMXContext *ctx, ace_config *ace) { ctx_range.range_card.card = calloc(ctx_range.range_card.records, sizeof(RangeCardRecord)); + assert(ctx_range.range_card.card); Vec3 wind1 = { .x = cos(270 - ctx->atmosphere.wind_dir * 30) @@ -155,7 +159,7 @@ ATragMXSolution *ATragMXCalcSolution(ATragMXContext *ctx, ace_config *ace) { bullet.pos = vec3_add(bullet.pos, vec3_mul(bullet.velocity, bullet.deltaT * 0.5)); - sln->time_of_flight = sln->time_of_flight + bullet.deltaT; + sln->time_of_flight += bullet.deltaT; // continue here if (ctx->store_range_card) { @@ -206,7 +210,7 @@ ATragMXSolution *ATragMXCalcSolution(ATragMXContext *ctx, ace_config *ace) { if (ace->ballistics->enabled && bullet.pos.y > 0) { // Coriolis local_solution.h_coriolis_deflection = - 0.0000729 * bullet.pos.y * local_solution.time_of_flight + 0.0000729 * bullet.pos.y * sln->time_of_flight * sin(ctx->target.latitude); local_solution.h_coriolis = @@ -230,7 +234,7 @@ ATragMXSolution *ATragMXCalcSolution(ATragMXContext *ctx, ace_config *ace) { local_solution.spin_deflection = ctx->gun.twist_dir * 0.0254 * 1.25 * (ctx->stability_factor + 1.2) - * pow(local_solution.time_of_flight, 1.83); + * pow(sln->time_of_flight, 1.83); local_solution.spin_drift = - atan(local_solution.spin_deflection / bullet.pos.y); @@ -256,7 +260,7 @@ ATragMXSolution *ATragMXCalcSolution(ATragMXContext *ctx, ace_config *ace) { (ctx_range.range_card.card+ctx_range.n)->lead = sln->lead; (ctx_range.range_card.card+ctx_range.n)->time_of_flight - = local_solution.time_of_flight; + = sln->time_of_flight; (ctx_range.range_card.card+ctx_range.n)->bullet_speed = bullet.speed; (ctx_range.range_card.card+ctx_range.n)->kinetic_energy = kinetic_energy; @@ -273,7 +277,7 @@ ATragMXSolution *ATragMXCalcSolution(ATragMXContext *ctx, ace_config *ace) { if (ace->ballistics->enabled && bullet.pos.y > 0) { // Coriolis local_solution.h_coriolis_deflection = 0.0000729 * bullet.pos.y * - local_solution.time_of_flight * + sln->time_of_flight * sin(ctx->target.latitude); local_solution.h_coriolis = @@ -294,7 +298,7 @@ ATragMXSolution *ATragMXCalcSolution(ATragMXContext *ctx, ace_config *ace) { // Spin drift local_solution.spin_deflection = ctx->gun.twist_dir * 0.0254 * 1.25 * (ctx->stability_factor + 1.2) * - pow(local_solution.time_of_flight, 1.83); + pow(sln->time_of_flight, 1.83); local_solution.spin_drift = -atan(local_solution.spin_deflection / bullet.pos.y); @@ -307,7 +311,6 @@ ATragMXSolution *ATragMXCalcSolution(ATragMXContext *ctx, ace_config *ace) { sln->windage.w1 = local_solution.windage.w1 * 60.0; sln->windage.w2 = local_solution.windage.w2 * 60.0; sln->lead = local_solution.lead; - sln->time_of_flight = local_solution.time_of_flight; sln->remaining_velocity = bullet.speed; sln->remaining_energy = kinetic_energy; sln->coriolis_vdrift = local_solution.v_coriolis * 60.0; |
