forked from Jetina/AirfoilOpt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
naca4.m
43 lines (32 loc) · 913 Bytes
/
naca4.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function [x,y] = naca4(naca,npanel,x,y)
m=naca(1)/100;
p=naca(2)/10;
t=naca(3)/100;
% compute thickness and camber distributions
if mod(npanel,2) ~= 0
sprintf('Please choose an even number of panels');
sprintf('Exiting...');
exit;
end
nside = npanel / 2 +1;
% camber distribution
for i=1:nside
xx(i) = (1-cos(i*pi/nside))/2; %full cosine spacing
%xx(i) = 1-cos(i*pi/(2*nside)); %half cosine spacing
yt(i) = ( 0.29690*sqrt(xx(i)) -0.12600*xx(i) ...
-0.35160*xx(i)^2 +0.28430*xx(i)^3 ...
-0.10360*xx(i)^4) * t / 0.20;
if xx(i) < p
yc(i) = m/p^2 * (2*p*xx(i) -xx(i)^2);
else
yc(i) = m/(1 -p)^2 * ((1 -2*p) + 2*p*xx(i)-xx(i)^2);
end
end
% airfoil shape = camber + thickness
for i=1:nside
x(nside+i-1) = xx(i);
x(nside-i+1) = xx(i);
y(nside+i-1) = yc(i) +yt(i);
y(nside-i+1) = yc(i) -yt(i);
end
return