What is the best way to loft between multiple 2d sections

12 views (last 30 days)
I have a program where I load multiple 2d aerofoil sections from text files. I now want to interpolate between them in order to define an entire wing in terms of x,y,z coordinates. These will eventually be used in determining the mass of the wing from a point z to the tip. I have tried playing with interp1 and interp3 but can't figure out the best way to get the results I want. Should I define eachaerofoil section in terms of x,y,z, and if so how are multiple sections provided to interp, or am I going about this in the wrong way. THanks

Answers (2)

Sean de Wolski
Sean de Wolski on 29 Oct 2012
This sounds like something for TriScatteredInterp, sinc eit does not sound like you have gridded data.
doc triscatteredinterp
  1 Comment
Reuben
Reuben on 4 Nov 2012
Thanks for your answer, I've had a play with TriScattred interp but can't seem to achieve what I want as it requires two inputs to find an interpolated value for that point. Where as I require all x,y values for a given z value. I've added my test code below in the hope this makes it clearer.
% Test where I try to find the (x,y,z) surface of a kind
% of cone with the top cut off (Conical Frustum).
% Radii of bottom and top circles
r1 = 5;
r2=1;
% Values of i used to make circles, in actual case xs and ys at a given z
% may not be the same length as xs and ys at another z
i = 0:pi/50:2*pi;
i = i';
% Creating the bottom circles
x1 = r1*sin(i);
y1 = r1*cos(i);
x2 = r2*sin(i);
y2 = r2*cos(i);
x = [x1;x2];
y = [y1;y2];
% One circle is at z = 1, one circle is at z = 10
z1 = linspace(1,1,length(x1));
z2 = linspace(10,10,length(x1));
z = [z1 z2];
z = z';
% Tried a delauney triangulation as I ran out of other ideas.
DT = DelaunayTri(x,y);
F = TriScatteredInterp(DT,z);
% Now find the circle in the xy plane at z = 2.5
radial_loc = 2.5;
[x,y] = F(2.5); % can't do this.

Sign in to comment.


Strider
Strider on 26 Mar 2024
I was able to find a solution to my need. I am making use of a custom class object that handles things like giving me the top / bottom surface of an airfoil. This is a method of that class that returns interpolated vertices based on two input airfoils, the distance between them, and the desired location of the new airfoil.
function val = interpolate(obj, dx, vq)
arguments (Input)
obj Base % custom class object array of airfoils
dx (1,1) double % distance between two airfoils to interpolate
vq (1,1) double % distance to interpolate at
end
% must split airfoil into top and bottom surfaces
% my Base object does this and is accessed by a property call
surface = {'Top', 'Bottom'};
for k = 1 : 2
% grab surface
v1 = obj(1).(surface{k}); % top or bottom of first airfoil
v2 = obj(2).(surface{k}); % top or bottom of second airfoil
% cat known points
x = [v1(:,1); v2(:,1)]; % x values for AF1 and AF2
y = [v1(:,2); v2(:,2)]; % y values for AF1 and AF2
% for simplicity, AF1 may be assumed to be at 0.
% AF2 is then at 0 + dx
v = [repelem(0, length(v1))'; repelem(dx, length(v2))'] ;
% our airfoil is a function of x and z
% af = f(x,z)
% query at all old x and new point z.
F = scatteredInterpolant(x, v(:,1), y);
% query new points
af = F(x,[repelem(vq,length(x))]'); % new y values
% cat and sort
a = [x af];
S.(surface{k}) = sortrows(a,1);
end
vert = [S.Top; flip(S.Bottom)]; % new airfoil vertices
end

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!