%***********************************************************************************
% 
% Yawing Force Subfunction
% Primary authors: Kacie Burton, Kevin Dahya, Mellisa Glaser, Kerem Koray
% Wael Nour, and Tanya Tunistra
% AAE 421 Design Project Spring 2001
%
%***********************************************************************************

function [Cno,Cn_beta,Cn_delta_a,Cn_delta_r,Cnp,Cnr]=yawingforce(CL,Cl_delta_a,Cy_dr,alpha,b,Cl_alpha_w,beta,xbar_cg,xbar_ac,A,lambda,cbar,Cl_p,B,l_v,Cy_Beta_v,Z_v,lambda_c4,theta,ad_cl)

% These equations were given in Roskam, Methods for Estimating Stability and Control Derivative os Conventional Subsonic Airplanes

Cno=0
Cn_beta=0.11												%From Boiler Xpress AAE 451 final report
K=-.175;														%From Figure 11.3 in Roskam Handout
Cn_delta_a=K*CL*Cl_delta_a								%Eqn 11.9 in Roskam Handout
Cn_delta_r=-Cy_dr*(l_v*cos(alpha)+Z_v*sin(alpha))/b	%Eqn 12.3 in Roskam Handout
kappa=Cl_alpha_w/(2*pi);								%Found in Sec. 8.2 in Roskam Handout
beta_Clp_kappa=-.4;										%From Figure 8.1 in Roskam Handout
Clpw=beta_Clp_kappa*kappa/beta;						%Eqn 8.3 in Roskam Handout
xbar=xbar_cg-xbar_ac;									%Taken from the brains of Mellisa, Kacie, and Kevin
Cnp_Cl_M=-1/6*((A+6*(A+cos(lambda_c4))*(xbar/cbar*tan(lambda_c4)/A+(tan(lambda_c4))^2/12))/(A+4*cos(lambda_c4)));	%at M=0  Eqn 8.10 in Roskam Handout (rad-1)
Cnp_Cl=((A+4*cos(lambda_c4))/(A*B+cos(lambda_c4)))*((A*B+1/2*(A*B+cos(lambda_c4))*(tan(lambda_c4))^2)/(A+1/2*(A*cos(lambda_c4))*(tan(lambda_c4))^2))*Cnp_Cl_M;	%Eqn 8.8 in Roskam Handout 
delta_Cnp_theta=0.00045;								%From Figure 8.2 in Roskam Handout
delta_Cnp_alpha_deltaf_deltaf=0;						%No flaps, found in Sec. 8.3 in Roskam Handout
deltaf=0;													%No flaps, found in Sec. 8.3 in Roskam Handout
Cnpw=-Clpw*tan(alpha)-(-Cl_p*tan(alpha)-Cnp_Cl*CL)+delta_Cnp_theta*theta+delta_Cnp_alpha_deltaf_deltaf*ad_cl;	%Eqn 8.7 in Roskam Handout
Cnpv=-2/b*(l_v*cos(alpha)+Z_v*sin(alpha))*((Z_v*cos(alpha)-l_v*sin(alpha))/b)*Cy_Beta_v;	%Eqn 8.11 in Roskam Handout
Cnp=Cnpw+Cnpv												%Eqn 8.6 in Roskam Handout

Cnr_Clsq=-.03;												%From Figure 9.4 in Roskam Handout
Cnrw=Cnr_Clsq*CL^2;										%Eqn 9.10 in Roskam Handout
Cnrv=(2/(b^2))*(l_v*cos(alpha)+Z_v*sin(alpha))^2*Cy_Beta_v;	%Eqn 9.11 in Roskam Handout
Cnr=Cnrw+Cnrv												%Eqn 9.9 in Roskam Handout
