clear
r=load('kepler.dat');
z=r(:,1)*0;
%lisa parameetrid
kor=384399.;
kok=1.022;
mkr=6378.;
fi0=-pi*60./180.;
omegak=kok/kor;

%Maakera koordinaadid
th = 0:pi/50:2*pi;
xmaa =  cos(th);
ymaa = sin(th);

%aeg
t=r(:,1);

%kuu koordinaadid
x=kor*cos(omegak*t+fi0)./mkr;
y=kor*sin(omegak*t+fi0)./mkr;

%visualiseerimine
figure('Position',[10,10,900,900])

subplot(2,2,1)
plot(xmaa, ymaa);
title('trajektoor')
axis equal
xlabel('x')
ylabel('y')
hold on

%%Animatsioon
%nt=size(t)
%h=animatedline();
%h1=animatedline();
%for i=1:100:nt
%addpoints(h,r(i,2)/mkr,r(i,3)/mkr);addpoints(h1,r(i,6)/mkr,r(i,7)/mkr);
%F(i)=getframe;
%end
plot (r(:,2)/mkr,r(:,3)/mkr)
plot (r(:,6)/mkr,r(:,7)/mkr)
grid on

subplot (2,2,2)
plot(r(:,1),r(:,10))
title('sat kirus')
xlabel('t sek')
ylabel('v km/sek')
grid on

subplot (2,2,3)
plot(r(:,1),r(:,9)/mkr)
title('sat-kuu')
xlabel('t sek')
ylabel('sat-kuu')
grid on

subplot (2,2,4)
plot(r(:,1),r(:,8)/mkr)
title('sat-maa')
xlabel('t sek')
ylabel('sat-maa')
grid on
