kill(all)$

load("lrats")$

Orbital position as a function of 'time',measured from the peri-point.  'version 1.0'
peter.vlasschaert@gmail.com,24/06/2018.

rem :'missile flight ' ,center earth = focus, peri-point stays in the earth below the focus.

see : orbit stays in one plane : h ? 'see website'
--------------------------------------------------------------------------
see : geometry of trajectory of 'missile flight',part 2:ellipse geometry
------------------------------------------------------------------------------------------------------------

1e) relation between 'time' and 'θ' from polar equation.
h = r*(r*d0/dt) =r*v=r^2*dθ/dt 
===========================================

p1:dθ/dt = h/r^2;

2e) polar equation 
===============

p2:r=p/(1+e*cos(θ));

 ? where peri-point 'polar equation 'p2'  ',lowest point

Answer :  θ =0 ,r=r_p ,p = peri-point.
--------------------------------------------------------

p2a:lratsubst([r=r_p,θ =0],p2);

? where apo-point 'polar equation 'p2'',highest point

Answer : θ = π,r=r_a , a = apo-point.
--------------------------------------------------------

p2b:lratsubst([r=r_a,θ =%pi],p2);
p2c:expand(p2b);

 ? definition : ellips : 'r_a+r_p = 2*a '

p3:p2a+p2c;

p3a: rhs(p3) = 2*a;

find :  p ?, polar equation to draw , e ,a : given
=====================================

1e) p  ?
-----------

p3b:solve(p3a,p)[1];

find : factorout 'a' , 'p3c'

p3c:lhs(p)=coeff(rhs(p3b),a)*a;

2e)    given a,e  : draw 'r'
---------------------------------------

p3d:subst([p3c],p2);

rem :   p= h^2/μ = a*(1-e^2) ,other def's

Find : flight time in the orbit from the 'peri-point' as references.
================================================= =

1e) def ,from above
-------------------------------

p4:p=h^2/μ;

2e)  put 'p' into 'p2'
-----------------------------

p4a:subst([p4],p2);

3e) put  'r '  into 'p1'
-------------------------------

p4b:subst([p4a],p1);

p4c:p4b*dt;

rem : separation of variables =  'θ,t'
--------------------------------------------------------

p4d:p4c/(e*cos(θ)+1)^2;

coef:dθ
======

p5a:coeff(lhs(p4d),dθ);

coef:dt
=====

p5b:coeff(rhs(p4d),dt);

rem : integration t : t_p  to  t
         ==================
         integration θ : 0    to  θ
         ==================

symbolic : representation : flight time.
==============================
==============================

p6:'integrate(p5a,θ,0,θ) = 'integrate(p5b,t,t_p,t);

reference : t_p = 0; p  = peri-point .

p6a:subst([t_p=0],p6);

p6b:solve(p6a,t);

p6c:p6b[1];

from : integral ellipse 'website: part : rocket science'
 e < 1,q=tan(x/2)

time of flight ( = t_f): when the orbit ellipse.
==================================
==================================

assume(e<1);

given : website 'integral ellipse'

p7:'integrate(1/(a1*cos(x)+a2)^2,x,0,x)=(2*a2*atan((sqrt(a2-a1)*q)/sqrt(a2+a1))-(a1*sqrt(a2^2-a1^2)*sin(x))/(a1*cos(x)+a2))/(a2^2-a1^2)^(3/2);

solve 'p6c' elliptical orbit. 
====================
a1 = e
a2 = 1
x   = θ
q = tan(θ/2)
====================
e =eccentricity < 1  :elliptical.
θ = true anomaly. ( = polar equation)
=============================

p7a:[a1=e,a2=1,x=θ,q=tan(θ/2)];

p7b:subst(p7a,p7);

p7c: [t=t_f];

p7d:subst(p7c,p6c);

p7d1:h^3/μ^2;

find :coef from :h^3/μ^2 from 'p7d'
===========================

p7e:ratcoeff(rhs(p7d),p7d1);

from 'p7b' the 'rhs'

p7f:rhs(p7b);

final:result, time of flight :measured from peri-point :ref
============================================

p7g:lhs(p7d)=p7d1*p7f;

?   find  =>  DEF :Mean anomaly : M_e
==============================

p8:part(p7f,1);

p8a:part(p7f,2);

p8b:M_e = p8;

time flght :through elliptical orbit ,with use M_e
======================================

p8c:lhs(p8b)=1/p7d1*(p8a)*lhs(p7g);

p8d:solve(p8c,t_f);
p8e:p8d[1];

period : T (=time) of orbit  => relation between : M_e, T
===========================================

p9:M_e/(2*%pi)=t_f/T;

ratio = are values with no units .

p9a:solve(p9,M_e);
p9b:p9a[1];

DEF : Mean motion = n
==================

p9c:n=ratcoeff(rhs(p9b),t_f);

relation between : n,M_e
====================

p10:lhs(p9b)=lhs(p9c)*t_f;

------------------------------------------------------------------------------------------------------------------------------------------------------------------