-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathecc_anomaly_from_M.m
More file actions
35 lines (32 loc) · 815 Bytes
/
Copy pathecc_anomaly_from_M.m
File metadata and controls
35 lines (32 loc) · 815 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
28
29
30
31
32
33
34
35
function E = ecc_anomaly_from_M(e, M)
%% Calculates the eccentric anomaly
%
% Jeremy Penn
% 22 October 2017
%
% Revision 22/10/17
%
% function E = ecc_anomaly(e, M)
%
% Purpose: This function calculates the eccentric anomaly given the
% eccentricity and mean anomaly.
%
% Inputs: o e - Eccentricity
% o M - Mean anomaly [radians]
%
% Outputs: o E - Eccentric anomaly [radians]
%
%% Choose initial estimate for E
if M < pi
E = M + e/2;
else
E = M - e/2;
end
%% Calculate the ratio to given tolerance
tol = 1e-08;
ratio = 1;
while abs(ratio) > tol
ratio = (E - e*sin(E) - M)/(1 - e*cos(E));
E = E - ratio;
end
end