close all
clear all

[rho S Cp C ] = Constants();
C4 = C/4;


U = 0.5;

aoa = (0:180)*pi/180;
[cl cd cm]=Coef0015(aoa);


qinf = .5*rho*U.^2;
M0 = S*qinf*C^2;
F0 = S*qinf*C;

L = cl*F0;
D = cd*F0;
M = cm*M0;

figure
subplot(3,1,1)
plot(aoa*180/pi,L);
hold all
plot(aoa*180/pi,D);
grid on
ylabel('N');
legend('Lift','Drag');
title(['Cp = ' num2str(Cp/.0254) ' in  U = ' num2str(U) ' m/s']);
subplot(3,1,2)
plot(aoa*180/pi,cm*M0);
hold on
plot(aoa*180/pi,L*(Cp-C4).*cos(aoa))
plot(aoa*180/pi,D*(Cp-C4).*sin(aoa));
ylabel('N-m');
legend('C/4 Moment', 'Moment Due to Lift',' Moment Due to Drag');

grid on
subplot(3,1,3)
plot(aoa*180/pi,M+L*(Cp-C4).*cos(aoa)+D*(Cp-C4).*sin(aoa));
ylabel('N-m');
legend('Total Moment');
grid on


figure
plot(aoa*180/pi,cm);
hold all
plot(aoa*180/pi,cl*((Cp-C4)/C).*cos(aoa));
plot(aoa*180/pi,cd*((Cp-C4)/C).*sin(aoa));
plot(aoa*180/pi,cm+cl*((Cp-C4)/C).*cos(aoa)+cd*((Cp-C4)/C).*sin(aoa));
legend('cm\_pivot','cml\_pivot','cdl\_pivot','sum');
ylabel('Moment Coefficients');
title(['Cp = ' num2str(Cp/.0254) ' in ']);

grid on

xlabel('Angle of Attack; Degrees')
  
  
  