summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhybrid <hybrid@hybridlabs.cc>2026-08-21 17:28:02 +0300
committerhybrid <hybrid@hybridlabs.cc>2026-08-21 17:28:02 +0300
commitca33e8422977a35fd01558e82748dc203b42c1dd (patch)
tree0bedf0fc6ba93a7b58fee6c60b1a47895dde9445
parent7ad9c60cdb981d51756755dca4603e77611a0f61 (diff)
downloada3catragmx-ca33e8422977a35fd01558e82748dc203b42c1dd.tar.gz
a3catragmx-ca33e8422977a35fd01558e82748dc203b42c1dd.tar.bz2
a3catragmx-ca33e8422977a35fd01558e82748dc203b42c1dd.zip
upd: tmpHEADmain
-rw-r--r--example/example.c2
-rw-r--r--include/context.h2
-rw-r--r--src/atragmx.c17
-rw-r--r--src/main.c10
4 files changed, 12 insertions, 19 deletions
diff --git a/example/example.c b/example/example.c
index 977a8ae..bfe843b 100644
--- a/example/example.c
+++ b/example/example.c
@@ -71,7 +71,7 @@ int main(int argc, char** argv) {
if (ctx.store_range_card && result->range_card != NULL) {
printf("\nRange card (sim_steps = %zu):\n", ctx.sim_steps);
for (size_t i = 0; i < ctx.sim_steps; i++) {
- printf(" шаг %3zu: %.3f\n", i, result->range_card->card->kinetic_energy);
+ printf(" step %3zu: %.3f\n", i, (result->range_card->card+i)->kinetic_energy);
}
}
diff --git a/include/context.h b/include/context.h
index ce5f913..5c07be3 100644
--- a/include/context.h
+++ b/include/context.h
@@ -82,7 +82,7 @@ typedef struct {
double coriolis_vdrift;
double coriolis_hdrift;
double spin_drift;
- RangeCard *range_card;
+ RangeCard range_card;
} ATragMXSolution;
#endif
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;
diff --git a/src/main.c b/src/main.c
deleted file mode 100644
index 6a74fa7..0000000
--- a/src/main.c
+++ /dev/null
@@ -1,10 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "context.h"
-#include "atragmx.h"
-
-int main(int argc, char** argv) {
- printf("Hello, %s\n", argv[0]);
- exit(EXIT_SUCCESS);
-}