(*"Measuring the Earth-Sun system";*)

h=0;k=0;G=6.63*10^(-11);
e=0.0167086;
a=1.496*10^(11);b=a*Sqrt[1-e^2];
MS=1.989×10^30 ;
T=2Pi*Sqrt[a^3/(G*MS)];
omega0=2Pi/T;
(*** define linear eccentricity f *)
f1=Sqrt[a^2-b^2];f2=-f1;
(*f1=f1+h;f2=h+f2;*)
F1={f1+h,k};F2={f2+h,k};
(*** end of define focal points*)

(* Define the end points of major and minor axes *)
esMl={h-a,k};esMr={a+h,k};
esmu={h,b+k};esmd={h,k-b};
lsM=Graphics[Line[{esMl,esMr}]];
lsm=Graphics[Line[{esmu,esmd}]];

(**** for the E-Sun ****)
x[t_]:=a*Cos[omega0*t]+h;
y[t_]:=b*Sin[omega0*t]+k;
prp1=ParametricPlot[{x[t],y[t]},{t,0,T},PlotRange->{{h-a,h+a},{k-b,k+b}}];
pp2=Graphics[{PointSize->0.03,Point[{h,k}]}];
ppf=Graphics[{PointSize->0.02,Point[{F1,F2}]}];
(**** for the E-Sun ****)

(*"Simuate the motion of a moving point overlapping on the ellipse using Manipulate";*)
Manipulate[
gp=Graphics[{Red,PointSize->0.02,Point[{x[t],y[t]}]}];
Show[{prp1,ppf,pp2,lsM,gp}]
(*Show[{prp1,ppf,pp2,lsM,gp}]*)
,
{t,0.0,10T,0.005T}
];

Deltat=0.005T;
(*** measuring radius of Earth wrt Sun as function of time **)
rES[t_]:=Sqrt[(x[t]-f1)^2+(y[t]-k)^2];
(*
p=(b^2)/a;(*semi-latus rectum*)
lmin=p/(1+e);
*)
(*plotlabel="reduced distance of E from S (wrp lmin) as function of time (in s)";*)
plotlabel="Distance of E from S (in m) as function of time (in s)";
Plot[rES[t],{t,0,T},PlotLabel->plotlabel]
(*** measuring radius of Earth wrt Sun as function of time **)

(*** measuring speed of planet as function of time **)
Deltar[t_]:=Sqrt[(x[t+Deltat]-x[t])^2+(y[t+Deltat]-y[t])^2];
v[t_]:=Deltar[t]/Deltat;
(*v[t_]:=omega[t]*rES[t];*)
plotlabel="speed of E wrp to S (in m/s) as function of time (in s)";
Plot[v[t],{t,0,T},PlotLabel->plotlabel]
(*** end of measuring speed of planet as function of time **)