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

function [CLo,Cl_Beta,Cl_delta_a,Cl_p,Cl_delta_r,Cl_r,ad_cl]=rollingforce(CL,gamma,Z_v,alpha,b,Cy_Beta_v,Cl_alpha_v,K_prime,Kb,S_ver,Sref,B,lambda_c4,theta,l_v,A)

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

CLo=0
Clb_Cl_alpha=-.0005;											%From Figure 7.14 in Roskam Handout
Clb_gamma=-.00025;											%From Figure 7.15 in Roskam Handout
K_M_gamma=1;													%From Figure 7.16 in Roskam Handout, M assusmed 0 "because we're going too frickin' slow" -Kacie Burton
Cl_Beta_wb=57.3*(CL*Clb_Cl_alpha)+gamma*Clb_gamma*K_M_gamma;	%Eqn 7.9 of Roskam Handout
Cl_Beta_h=0;													%assumed 0 because the ratio between the horizontal tail area and the wing is small  in Roskam Handout
Cl_Beta_v=(Z_v*cos(alpha)-l_v*sin(alpha)/b)*Cy_Beta_v;	%Eqn 7.14 in Roskam Handout (rad-1)
Cl_Beta=Cl_Beta_wb+Cl_Beta_h+Cl_Beta_v					%Eqn 7.8 in Roskam Handout
Cl_delta_a=0.8													%Taken from Boiler Xpress AAE 451 final report
Cl_p=-.15														%Taken from Boiler Xpress AAE 451 final report
ad_CL_ad_cl=1.3;												%From Figure 10.2 in Roskam Handout
ad_cl=0;															%From Figure 10.2, no flaps in Roskam Handout
Cy_delta_r=Cl_alpha_v*ad_CL_ad_cl*ad_cl*K_prime*Kb*S_ver/Sref;	%Eqn 12.1 in Roskam Handout
Cl_delta_r=Cy_delta_r*((Z_v*cos(alpha)-l_v*sin(alpha))/b)	%Eqn 12.2 in Roskam Handout
Cl_r_CL_M=.26;													%From Figure 9.1 in Roskam Handout, CL when M=0 
Cl_r_CL=(1+(A*(1-B^2)/2*B*(A*B+2*cos(lambda_c4))+(A*B+2*cos(lambda_c4)*(tan(lambda_c4))^2)/(8*(A*B+4*cos(lambda_c4))))/(1+(A+2*cos(lambda_c4)*(tan(lambda_c4))^2)/(8*(A+4*cos(lambda_c4)))))*Cl_r_CL_M;	%Eqn 9.5 in Roskam Handout
dCl_r_gamma=pi*A*sin(lambda_c4)/(12*(A+4*cos(lambda_c4)));	%Eqn 9.7 in Roskam Handout (rad-1)
dCl_r_theta=-.009;											%From Figure 9.2 in Roskam Handout
dCl_r_alpha_df_df=0;											%From Figure 9.3 in Roskam Handout, no flaps
alpha_df_df=0;													%From section 10.1 in Roskam Handout, no flaps
Cl_rw=CL*Cl_r_CL+dCl_r_gamma*gamma+dCl_r_theta*theta+dCl_r_alpha_df_df*alpha_df_df;	%Eqn 9.4 in Roskam Handout (rad-1)
Cl_rv=(-2/b^2)*(l_v*cos(alpha)+Z_v*sin(alpha))*(Z_v*cos(alpha)-l_v*sin(alpha))*(Cy_Beta_v);	%Eqn 9.8 in Roskam Handout
Cl_r=Cl_rw+Cl_rv												%Eqn 9.3 in Roskam Handout
