-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEllipticOrbit.m
More file actions
27 lines (23 loc) · 885 Bytes
/
EllipticOrbit.m
File metadata and controls
27 lines (23 loc) · 885 Bytes
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
classdef EllipticOrbit < Orbit % ecc < 1
methods
% Constructor
function obj = EllipticOrbit(sma, ecc, inc, arg, lan, mna)
obj = obj@Orbit(sma, ecc, inc, arg, lan, mna);
end
% Return position and velocity at any given time
function [r, v] = toIJK(obj, t)
% init
global GM options;
mu = GM;
% orbit2mna
p = obj.sma * (1 - obj.ecc^2);
h = sqrt(mu * p);
M = obj.mna + (mu^2 / h^3) * (1 - obj.ecc^2)^(3/2) * t;
% mna2tea
f = @(E) E - obj.ecc * sin(E) - M;
E = fsolve(f, pi, options);
tea = 2 * atan(sqrt((1 + obj.ecc) / (1 - obj.ecc)) * tan(E / 2)); % aka: theta, nu
[r, v] = toIJK@Orbit(obj, p, tea, mu);
end
end
end