-
Notifications
You must be signed in to change notification settings - Fork 1
/
orbit_plane_change.zig
49 lines (40 loc) · 1.6 KB
/
orbit_plane_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
47
48
49
const std = @import("std");
const math = std.math;
const astroz = @import("astroz");
const Tle = astroz.Tle;
const constants = astroz.constants;
const Impulse = Spacecraft.Impulse;
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 plane_change_maneuver = Impulse{
.time = 2500000.0,
.delta_v = .{ 0.0, 0.0, 0.0 }, // Not used for plane changes
.mode = .Plane_Change,
.plane_change = .{
.delta_inclination = math.pi / 18.0, // 10-degree inclination change
.delta_raan = math.pi / 36.0, // 5-degree RAAN change
},
};
const impulses = [_]Impulse{plane_change_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});
}
}