-
Notifications
You must be signed in to change notification settings - Fork 6
/
ECI2ECEF.m
59 lines (53 loc) · 1.87 KB
/
ECI2ECEF.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
58
59
function [X_ECEF,V_ECEF] = ECI2ECEF(X_ECI,V_ECI,GMST)
%% DESCRIPTION
%
% Written by: Tyler Reid
% Lab: Stanford GPS Lab
% Project Title: Arctic Navigation / WAAS
% Project Start Date: March 28, 2011
% Last updated: April 18, 2011
%
% -------------------------------------------------------------------------
% FUNCTION DESCRIPTION
%
% Given the X,Y,Z coordinates of a spacecraft in ECI coordintes and the
% Greenwich Mean Sidereal Time (GMST), compute the position vector of the
% spacecraft in the ECEF frame.
%
% -------------------------------------------------------------------------
% INPUT:
%
% X_ECI = ECI position vector of the spacecraft [length]*
% V_ECI = ECI velocity vector of the spacecraft [length/time]*
% GMST = Greenwich mean sidereal time [rad]
%
% -------------------------------------------------------------------------
%
% OUTPUT:
%
% X_ECEF = ECEF position vector of the spacecraft [length]*
% V_ECI = ECI velocity vector of the spacecraft [length/time]*
%
% -------------------------------------------------------------------------
%
% NOTES:
%
% * this quantity can be expressed in any length/time unit, the output
% will be consistant with the input
%
%% DEFINE GLOBAL VARIABLES USED
global omega_e
%% IMPLEMENTATION
% define the tranformation matrix
ECEF_C_ECI = [cos(GMST) sin(GMST) 0;-sin(GMST) cos(GMST) 0;0 0 1] ;
% determine if input arguments are column or row vectors
[m n] = size(X_ECI);
if m>n % input arguments are column vectors
X_ECEF = ECEF_C_ECI*X_ECI;
V_ECEF = ECEF_C_ECI*V_ECI;
elseif n>m % input arguments are row vectors
X_ECEF = X_ECI*ECEF_C_ECI';
V_ECEF = V_ECI*ECEF_C_ECI';
else
fprintf('Error in ECI2ECEF - matrix dimensions\n')
end