This document contains code to calculate the orbital elements of a celestial body given its radius and velocity vectors. It calculates the inclination (i), right ascension of the ascending node (RA), eccentricity (e), argument of perigee (AP), and true anomaly (Theta) based on the provided position and velocity data. The outputs give the calculated values for each orbital element.
This document contains code to calculate the orbital elements of a celestial body given its radius and velocity vectors. It calculates the inclination (i), right ascension of the ascending node (RA), eccentricity (e), argument of perigee (AP), and true anomaly (Theta) based on the provided position and velocity data. The outputs give the calculated values for each orbital element.
This document contains code to calculate the orbital elements of a celestial body given its radius and velocity vectors. It calculates the inclination (i), right ascension of the ascending node (RA), eccentricity (e), argument of perigee (AP), and true anomaly (Theta) based on the provided position and velocity data. The outputs give the calculated values for each orbital element.
%Used to Solve for the orbital elements of problem 2
% mu=398600 %Radius and Velocity Vectors R1=[-2429.1 4555.1 4577]; V1=[-4.7689 -5.6113 3.0535]; %Magnitude of Radius and Velocity Vector r1=norm(R1); v1=norm(V1); %Radial Velocity Vr=(dot(R1,V1))/r1; %Specific Angular Momentum Vector and Magnitude H=cross(R1,V1); h=norm(H); %Solving for i= Inclination Angle i= acosd(H(3)/h) %K vector defined K=[0 0 1]; %Node line Vector and Magnitude N=cross(K,H); n=norm(N); %Solving for RA= Right Ascension of the ascending node if N(2)>=0 RA= acosd(N(1)/n) elseif N(2)<0 RA=360-acosd(N(1)/n) end %Eccentricity Vector and Magnitude E=(1/mu)*(cross(V1,H)-(R1*(mu/r1))); e=norm(E); %Solving for AP= Argument of Perigee if E(3)>= 0 AP=acosd(dot(N,E)/(n*e)) elseif E(3)<0 AP=360-acosd(dot(N,E)/(n*e)) end %Solving for Theta= True Anomaly if Vr>=0 Theta=acosd((1/e)*((h.^2/mu*r)-1)) elseif Vr<0 Theta=360-acosd((1/e)*((h^2/mu*r1)-1)) end