-
Notifications
You must be signed in to change notification settings - Fork 6
/
liftsurfsection.m
94 lines (72 loc) · 2.59 KB
/
liftsurfsection.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
function [XUpper,YUpper,ZUpper,...
XLower,YLower,ZLower,...
FoilArea, FoilPerimeter,...
XUpperOriginal,...
ZUpperOriginal,...
XLowerOriginal,...
ZLowerOriginal] = ...
liftsurfsection(Airfoil, Chord,...
SpanwiseLoc, StreamwiseLoc, VerticalLoc,...
TwistAngle, DihedralAngle)
% Copyright: A. Sobester 2011
% Basic airfoil, chord = [0,1]
XUpper = Airfoil{1};
ZUpper = Airfoil{2};
XLower = Airfoil{3};
ZLower = Airfoil{4};
% Chord scaling
XUpper = XUpper*Chord;
ZUpper = ZUpper*Chord;
XLower = XLower*Chord;
ZLower = ZLower*Chord;
% Compute the airfoil cross sectional area
FoilArea = polyarea(XUpper,ZUpper) + polyarea(XLower,ZLower);
% Compute the perimeter of the airfoil
FoilPerimeter = 0;
for i=1:length(XUpper)-1
FoilPerimeter = FoilPerimeter + ...
sqrt((XUpper(i+1)-XUpper(i))^2 + (ZUpper(i+1)-ZUpper(i))^2);
end
for i=1:length(XLower)-1
FoilPerimeter = FoilPerimeter + ...
sqrt((XLower(i+1)-XLower(i))^2 + (ZLower(i+1)-ZLower(i))^2);
end
% Rotate the airfoil around the LE by the twist angle
[theta,rho] = cart2pol(XUpper,ZUpper);
[XUpper, ZUpper] = pol2cart(theta + TwistAngle*pi/180,rho);
[theta,rho] = cart2pol(XLower,ZLower);
[XLower, ZLower] = pol2cart(theta + TwistAngle*pi/180,rho);
% The original, scaled airfoil, before rotation, translation, etc.
XUpperOriginal = XUpper;
ZUpperOriginal = ZUpper;
XLowerOriginal = XLower;
ZLowerOriginal = ZLower;
% Rotate the airfoil around a line parallel with the x axis
% at its maximum z-coordinate point
% Drop the airfoil down so that the max point is on the x axis
MaxZ = max(ZUpper);
ZUpper = ZUpper - MaxZ;
ZLower = ZLower - MaxZ;
YUpper = zeros(size(XUpper));
YLower = zeros(size(XLower));
% Now rotate each point in the Z-Y plane
[theta,rho] = cart2pol(YUpper,ZUpper);
[YUpper, ZUpper] = pol2cart(theta + DihedralAngle*pi/180,rho);
[theta,rho] = cart2pol(YLower,ZLower);
[YLower, ZLower] = pol2cart(theta + DihedralAngle*pi/180,rho);
% Translate the airfoil back with its LE at the origin
XUpper = XUpper - XUpper(1);
YUpper = YUpper - YUpper(1);
ZUpper = ZUpper - ZUpper(1);
XLower = XLower - XLower(1);
YLower = YLower - YLower(1);
ZLower = ZLower - ZLower(1);
% Translate it streamwise
XUpper = XUpper + StreamwiseLoc;
XLower = XLower + StreamwiseLoc;
% Translate it vertically
ZUpper = ZUpper + VerticalLoc;
ZLower = ZLower + VerticalLoc;
% Translate it spanwise
YUpper = YUpper + SpanwiseLoc;
YLower = YLower + SpanwiseLoc;