Code covered by the BSD License  

Highlights from
Optimal Impulsive Orbital Transfer

Optimal Impulsive Orbital Transfer

by

 

27 Nov 2012 (Updated )

MATLAB script for the solution of the one and two impulse orbit transfer between two Earth orbits.

eci2lvlh (r, v, upeci)
function [uplvlh, pitch, yaw] = eci2lvlh (r, v, upeci)

% convert eci unit pointing vector to local
% vertical local horizontal coordinate system

% input

%  r     = eci position vector (kilometers)
%  v     = eci velocity vector (kilometers/second)
%  upeci = eci unit pointing vector (non-dimensional)

% output

%  uplvlh = lvlh unit pointing vector (non-dimensional)
%  pitch  = lvlh pitch angle (radians)
%           (-pi/2 <= pitch <= +pi/2)
%  yaw    = lvlh yaw angle (radians)
%           (0 <= yaw <= 2 pi)

% Orbital Mechanics with MATLAB

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% angular momentum vector

hvm = cross(r, v);
   
hvms = dot(hvm, hvm);
   
hvmag = sqrt(hvms);

% unit angular momentum vector

for i = 1:1:3
    
    hhat(i) = hvm(i) / hvmag;
    
end

rms = dot(r, r);
   
rmag = sqrt(rms);

% unit position vector

for i = 1:1:3
    
    rhat(i) = r(i) / rmag;
    
end

hr = cross(hhat, rhat);

% compute eci-to-lvlh transformation matrix

for j = 1:1:3
    
    tm(1, j) = -hhat(j);
    
    tm(2, j) = hr(j);
    
    tm(3, j) = rhat(j);
    
end

% perform transformation

for i = 1:1:3
    
    s = 0;
    
    for j = 1:1:3
        
        s = s + tm(i, j) * upeci(j);
        
    end
    
    uplvlh(i) = s;
    
end

% compute lvlh angles

pitch = asin(uplvlh(3));

yaw = atan3(uplvlh(1), uplvlh(2));

Contact us