forked from CCAR-ORCCA/MOID
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRefFrame.m
More file actions
38 lines (33 loc) · 1.22 KB
/
RefFrame.m
File metadata and controls
38 lines (33 loc) · 1.22 KB
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
function [incliB, omegaB, argpB] = RefFrame (A,B)
%% Reference frame rotation
% 3-1-3 Tranformation (orbital elements)
theta1 = A.Omega;
theta2 = A.i;
theta3 = A.argp;
RA = zeros (3,3); %from reference to A frame
RA(1,1) = cos(theta3)*cos(theta1)-sin(theta3)*sin(theta1)*cos(theta2);
RA(1,2) = sin(theta1)*cos(theta3)+cos(theta1)*cos(theta2)*sin(theta3);
RA(1,3) = sin(theta2)*sin(theta3);
RA(2,1) = -cos(theta1)*sin(theta3) - sin(theta1)*cos(theta2)*cos(theta3);
RA(2,2) = -sin(theta3)*sin(theta1) + cos(theta3)*cos(theta2)*cos(theta1);
RA(2,3) = sin(theta2)*cos(theta3);
RA(3,1) = sin(theta2)*sin(theta1);
RA(3,2) = -sin(theta2)*cos(theta1);
RA(3,3) = cos(theta2);
%% Preparing the orbit
x = [cos(B.Omega)*cos(B.argp) - sin(B.argp)*cos(B.i)*sin(B.Omega);
sin(B.Omega)*cos(B.argp) + sin(B.argp)*cos(B.i)*cos(B.Omega);
sin(B.i)*sin(B.argp)];
y = [-cos(B.Omega)*sin(B.argp) - cos(B.argp)*cos(B.i)*sin(B.Omega);
-sin(B.Omega)*sin(B.argp) + cos(B.argp)*cos(B.i)*cos(B.Omega);
sin(B.i)*cos(B.argp)];
z = [sin(B.i)*sin(B.Omega);
-sin(B.i)*cos(B.Omega);
cos(B.i)];
xn = RA * x;
yn = RA * y;
zn = RA * z;
incliB = atan2(sqrt(zn(1).^2 + zn(2).^2),zn(3));
omegaB = -atan2(zn(1),-zn(2));
argpB = -atan2(xn(3),yn(3));
end