-
Notifications
You must be signed in to change notification settings - Fork 3
/
Del2Eqn.m
57 lines (32 loc) · 1.06 KB
/
Del2Eqn.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
51
52
53
54
55
56
57
%% Delaunay elemets to Equinoctial Converter
% Del: [l,g,h,L,G,H];
% Poin: [a,psi,c(=h),d(=k),p,q];
% Author: Bharat Mahajan (https://github.com/princemahajan)
function [Y] = Del2Eqn(X,mu, toDel)
if toDel == true
a = X(1); Lambda = X(2); p1 = X(3); p2 = X(4); q1 = X(5); q2 = X(6);
% longitude of perihelion
gh = mod(atan2(q2,q1),2*pi);
l = Lambda - gh;
h = mod(atan2(p2,p1),2*pi);
g = mod(gh - h,2*pi);
L = sqrt(mu*a);
e = sqrt(q1^2 + q2^2);
G = L*sqrt(1 - e^2);
i = 2*atan(sqrt(p1^2 + p2^2));
H = G*cos(i);
Y = [l,g,h,L,G,H]';
else
% convert to Eqinoctial elements
l = X(1); g = X(2); h = X(3); L = X(4); G = X(5); H = X(6);
a = L^2/mu;
Lambda = l + mod(g + h,2*pi);
e = sqrt(1 - G^2/L^2);
q1 = e*cos(g + h);
q2 = e*sin(g + h);
i = acos(H/G);
p1 = tan(i/2)*cos(h);
p2 = tan(i/2)*sin(h);
Y = [a,Lambda,p1,p2,q1,q2]';
end
end