%% Test polára - vygeneruje rychlostní poláru z průběhů cL a cD
clear all;clc;close all;
brake = -60:0.1:50;
Fg = 80*9.80665;
%% Koeficienty samostatně 

cl = zeros(length(brake),1);
cd = zeros(length(brake),1);
for i = 1:length(brake);
    cd(i) = PG_cd(brake(i));
    cl(i) = PG_cl(brake(i));
end;
plot(brake,cd);
title('c_D');
grid;
figure;

plot(brake,cl);
title('c_L');
grid;
figure;
% tisk
% subplot(1,2,1);
% plot(brake,cl);
% grid;
% title('c_L');
% subplot(1,2,2);
% plot(brake,cd);
% grid;
% title('c_D');
% figure
% plot(cd,cl);
% grid;
%% Vykreslení poláry
vd = zeros(1,length(brake));
vo = zeros(1,length(brake));
for i=1:length(brake)
    CL = PG_cl(brake(i));
    CD = PG_cd(brake(i));
    gama = atan(CD/CL);
        
    v = sqrt(Fg/(sin(gama)*(CD+0.21)+CL*cos(gama)));        
    % v = sqrt(L/CL);
    vd(i) = v*cos(gama);
    vo(i) = v*sin(gama);

end;
 plot(vd,-vo,'ob-');
 axis equal;
 grid;
