-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathkep2car.m
53 lines (44 loc) · 1.1 KB
/
kep2car.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
function [r,v]=kep2car(kep,mu)
% kep2car.m
%
% PROTOTYPE:
% [r,v]=kep2car(kep,mu)
%
% DESCRIPTION:
% Function that switch keplerian parameters into cartesian coordinates
% (alternative mthod without v)
%
% INPUT:
% kep[6] Keplerian parameters of the orbit
% mu[1]
%
% OUTPUT:
% r[3] Position vector
% v[3] Velocity vector
%
% AUTHOR:
% Alfonso Collogrosso
%
a = kep(1);
e = kep(2);
i = kep(3);
OMG = kep(4);
omg = kep(5);
theta = kep(6);
% Semi latus rectum
p = a*(1 - norm(e)^2);
% Compute R position of S/C
R = p/(1 + norm(e)*cos(theta));
% Compute r perifocal
r_pf = [R*cos(theta);R*sin(theta);0];
% Compute v perifocal
v_pf = [-sqrt(mu/p)*sin(theta); sqrt(mu/p)*(norm(e) + cos(theta)); 0];
% Rotation matrix
RM_OMG = [ cos(OMG),sin(OMG), 0; -sin(OMG), cos(OMG), 0; 0, 0, 1];
RM_i = [1, 0, 0; 0, cos(i), sin(i); 0, -sin(i), cos(i)];
RM_omg = [cos(omg), sin(omg), 0; -sin(omg), cos(omg), 0; 0, 0, 1];
T = RM_OMG'*RM_i'*RM_omg';
% Compute v and r in geoceter equatorial system
r = T*r_pf;
v = T*v_pf;
end