Home » Posts tagged 'true anomaly'

# Tag Archives: true anomaly

## State vectors R & V from Orbital Elements

In this example we will show how to compute state vectors R and V in the geo-centric equatorial frame of reference using orbital elements

```clear all;
clc;
% Six  orbital elements are:
h    = 82000;      % [km^2/s] Specific angular momentum
i    = 50;         % [deg] Inclination
RAAN = 60;         % [deg] Right ascension (RA) of the ascending node
e    = 0.2;        % Eccentricity
omega= 90;         % [deg] Argument of perigee
theta= 35;         % [deg] True anomaly
mu = 398600;       % Earth’s gravitational parameter [km^3/s^2]
% Components of the state vector of a body relative to its perifocal
% reference
rx = h^2/mu*(1/(1 + e*cosd(theta)))*[cosd(theta);sind(theta);0];
vx = mu/h*[-sind(theta); (e +cosd(theta));0];
% Direction cosine matrix
QXx = [cosd(omega), sind(omega),0;-sind(omega),cosd(omega),0;0,0,1]*...
[1,0,0;0,cosd(i),sind(i);0,-sind(i),cosd(i)]*...
[cosd(RAAN), sind(RAAN),0;-sind(RAAN),cosd(RAAN),0;0,0,1];
% Transformation Matrix
QxX = inv(QXx);
% Geocentric equatorial position vector R
R = QxX*rx;
% Geocentric equatorial velocity vector V
V = QxX*vx;
fprintf('R = %4.2f*i +  %4.2f*j + %4.2f*k [km]\n',R);
fprintf('V = %4.4f*i +  %4.4f*j + %4.4f*k [km/s]\n',V);```
```R = -10766.25*i +  -3383.89*j + 9095.35*k [km]
V = -0.9250*i +  -5.1864*j + -2.1358*k [km/s]```

## Orbital elements from the state vector

Six orbital elements are: Specific angular momentum. Inclination. Right ascension (RA) of the ascending node. Eccentricity. Argument of perigee. True anomaly.

```clear all;
clc;
% Lets consider following example
% Given the state vector
R = [ -6132 -3380 2472];    %[km]
V = [-3.369 6.628 2.433];   %[km/s]
mu = 398600;                % Earth’s gravitational parameter [km^3/s^2]
r = norm(R);                % Radial distance
v = norm(V);                % Speed
vr = R*V'/r;                % Radial velocity
H = cross(R,V);             % Specific angular omentum
h = norm(H);                % Magnitude of the specifi c angular momentum
i = acos(H(3)/h)*180/pi;    % Inclination
K =[0 0 1];
N =cross(K,H);              % Node line vector
n = norm(N);                % Magnitude of N
% Right ascension of the ascending node
if(N(2) >= 0)
RAAN = acos(N(1)/n)*180/pi;
else
RAAN = 360 - acos(N(1)/n)*180/pi;
end
ev = 1/mu*((v^2-mu/r)*R-r*vr*V);    % Eccentricity vector
e  = norm(ev);                      % Eccentricity
% Argument of perigee,
if(ev(3) >= 0)
omega = acos(N*ev'/(n*e))*180/pi;
else
omega = 360 - acos(N*ev'/(n*e))*180/pi;
end
% True anomaly
if(vr >= 0)
theta = acos(ev*R'/(r*e))*180/pi;
else
theta = 360 - acos(ev*R'/(r*e))*180/pi;
end

OE = [h i RAAN e omega theta];
fprintf('h [km^2/s]    i [deg]     RAAN [deg]  e    omega[deg]   theta [deg] \n');
fprintf('%4.2f     %4.2f       %4.2f     %4.4f    %4.2f    %4.2f  \n',OE);```
```h [km^2/s]    i [deg]     RAAN [deg]  e    omega[deg]   theta [deg]
57932.08     153.91       255.01     0.1579    17.23    31.97```