close all
clear all


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


V = 1;

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



aoa = -60:60;

delta = 0:.5:2.5;

figure
for j = 1:length(delta)
    Cp =(2.8750-delta(j))*.0254;
leg_str{j} = (['delta = ' num2str(delta(j)) ' in       C/4-Cp = ' num2str((C/4-Cp)/.0254) ' in']);
for i = 1:length(aoa)
    
  [cl cd cm]=Coef0015(aoa(i)*pi/180);

  cl = 0.75*cl;  %Rough adjustment for finite span.

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

  M_wing(i) = M+L*(Cp-C4).*cos(aoa(i)*pi/180)+D*(Cp-C4).*sin(aoa(i)*pi/180);
  CM_wing(i) = M_wing(i)/M0;

%disp(['alpha = ' num2str(alpha)]);
end

plot(aoa,CM_wing);

hold on

end


xlabel('angle of attack');
ylabel('Moment Coeff around Pivot Point');
legend(leg_str);
grid on

print('-fillpage','-dpdf','NetWingMomentCoeff');