-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKeplers_Eqn.m
50 lines (45 loc) · 1.13 KB
/
Keplers_Eqn.m
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
function E_a = Keplers_Eqn(M, e)
%% DESCRIPTION:
%
% AA 279 - SPACE MECHANICS
%
% Problem Set # 2
% Problem 2.4
% Written by: Tyler Reid
% Date: April 14, 2011
%
% -------------------------------------------------------------------------
% FUNCTION DESCRIPTION
%
% Based on Vallado (2007) Algorithm 2
%
% Given the mean anomaly M, eccentricity e, compute the eccentric anomaly E
%
% -------------------------------------------------------------------------
% INPUT:
%
% e = eccentrity [-]
% M = mean anomaly [rad]
%
% -------------------------------------------------------------------------
%
% OUTPUT:
%
% E = eccentric anomaly [rad]
%
%% MAIN ALGORITHM
% Select initial guess.
if -pi<M<0 || M>pi
E_a = M-e;
else
E_a = M+e;
end
% Define tolerance.
tol = 1e-12;
test = 999; % Dummy variable.
% Implement Newton's method.
while test > tol
E_new = E_a + (M-E_a+e*sin(E_a))/(1-e*cos(E_a));
test = abs(E_new - E_a);
E_a = E_new;
end