-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpanelvortex.m
More file actions
44 lines (33 loc) · 936 Bytes
/
panelvortex.m
File metadata and controls
44 lines (33 loc) · 936 Bytes
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
function [ u, v ] = panelvortex( xs, ys, xe, ye, x, y )
% Velocity induced by unit-strength constrant strength vortex panel.
%
% xs, ys Panel vortex start
% xe, ye Panel vortex end
% x, y Point of interest
dxpan = xe - xs;
dypan = ye - ys;
lenpan = sqrt( dxpan.^2 + dypan.^2 );
dxp = dxpan ./ lenpan;
dyp = dypan ./ lenpan;
dxstart = x - xs;
dystart = y - ys;
lenssq = dxstart.^2 + dystart.^2;
lens = sqrt( lenssq );
dxs = dxstart ./ lens;
dys = dystart ./ lens;
dxend = x - xe;
dyend = y - ye;
lenesq = dxend.^2 + dyend.^2;
lene = sqrt( lenesq );
dxe = dxend ./ lene;
dye = dyend ./ lene;
dtheta = acos( dxe .* dxs + dye .* dys );
mask = ( dxs .* dye - dxe .* dys ) < 0;
dtheta( mask ) = -dtheta( mask );
% Velocity in panel coordinates
xi = ( dtheta ) ./ ( 2.0 * pi );
eta = ( log( lenesq ) - log( lenssq ) ) ./ (4.0 * pi );
% Transform back to global coords.
u = xi .* dxp - eta .* dyp;
v = xi .* dyp + eta .* dxp;
end