-
Notifications
You must be signed in to change notification settings - Fork 1
/
orbit_phase_change.zig
46 lines (37 loc) · 1.41 KB
/
orbit_phase_change.zig
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
const std = @import("std");
const math = std.math;
const astroz = @import("astroz");
const Tle = astroz.Tle;
const Impulse = Spacecraft.Impulse;
const constants = astroz.constants;
const Spacecraft = astroz.Spacecraft;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocator();
const test_tle =
\\1 55909U 23035B 24187.51050877 .00023579 00000+0 16099-2 0 9998
\\2 55909 43.9978 311.8012 0011446 278.6226 81.3336 15.05761711 71371
;
var tle = try Tle.parse(test_tle, allocator);
defer tle.deinit();
var test_sc = Spacecraft.init("dummy_sc", tle, 300.000, Spacecraft.SatelliteSize.Cube, constants.earth, allocator);
defer test_sc.deinit();
const phase_maneuver = Impulse{
.time = 2500000.0,
.delta_v = .{ 1.0, 0.0, 0.0 },
.mode = .Phase,
.phase_change = math.pi / 2.0,
};
const impulses = [_]Impulse{phase_maneuver};
try test_sc.propagate(
test_sc.tle.first_line.epoch,
3, // 3 days worth of orbit predictions
1, // steps, i.e. repredict every simulated second
&impulses,
);
for (test_sc.orbit_predictions.items) |iter| {
const r = math.sqrt(iter.state[0] * iter.state[0] + iter.state[1] * iter.state[1] + iter.state[2] * iter.state[2]);
std.debug.print("Next Prediction is: {any}\n", .{r});
}
}