1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "atragmx.h"
int main(int argc, char** argv) {
ATragMXSolution *result = NULL;
ATragMXContext ctx = {
.atmosphere = {
.atmosphere_model = ICAO,
.barometric_pressure = 1096.0,
.relative_humidity = 50.0,
.temperature = 15.2,
.wind_dir = 4,
.wind_speed = { 2.3, 2.7 }
},
.gun = {
.air_friction = 0.0,
.ballistic_coef = 0.4,
.bore_height = 0.08,
.bullet_mass = 10.0,
.drag_model = DRAG_G1,
.muzzle_velocity = 850.0,
.scope_angle = 0.0,
.twist_dir = 1,
},
.target = {
.speed = 5.5,
.direction = 5,
.inclination_angle = 12.3,
.latitude = 45.0,
.range = 625.0,
},
.sim_steps = 100,
.stability_factor = 1,
.store_range_card = true,
};
ace_ballistics ctx_ace_ballistics = {
.enabled = true,
};
ace_config ctx_ace = {
.ballistics = &ctx_ace_ballistics,
};
result = ATragMXCalcSolution(&ctx, &ctx_ace);
if (!result) {
perror("Calculation failed");
exit(EXIT_FAILURE);
}
printf("=== Solution ===\n");
printf("Elevation (radians): %.6f\n", result->elev);
printf("Windage W1: %.6f, W2: %.6f\n", result->windage.w1, result->windage.w2);
printf("Lead: %.6f\n", result->lead);
printf("Time of flight: %.4f s\n", result->time_of_flight);
printf("Remaining velocity: %.2f m/s\n", result->remaining_velocity);
printf("Remaining energy: %.2f J\n", result->remaining_energy);
printf("Coriolis vertical drift: %.6f\n", result->coriolis_vdrift);
printf("Coriolis horizontal drift: %.6f\n", result->coriolis_hdrift);
printf("Spin drift: %.6f\n", result->spin_drift);
assert(ctx.store_range_card);
assert(result->range_card != NULL);
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(" step %3zu: %.3f\n", i, (result->range_card->card+i)->kinetic_energy);
}
}
exit(EXIT_SUCCESS);
}
|