How do i find geometry properties of triangles?

I want to write a code to find the polar moment of inertia of an airfoil. Being a complex shape, a friend suggested a numerical estimate. I wrote a code to create the airfoil geometry and split it up into triangles using delaunay. I now need to find the moment of inertia about x and y for each triangle and use the parallel axis theorem to relate those to the centroid.
I have the delaunay triangulation complete but how can i find the Ix and Iy of each triangle? I don't even know where to start.
here's the code i have:
chord = 0.25; %chord of airfoil
nacanum = 12; % NACA XX## number for the airfoil
t = nacanum/100; %max thickness of airfoil
x=0:0.005:chord; %points along x axis from 0 to chord length
distratio = x/chord; %ratio of points along x to the chord
% function generating top half of airfoil
yt = 5*t*(0.2969*sqrt(distratio)-0.126*distratio-0.3516*distratio.^2+0.2843*distratio.^3-0.1015*distratio.^4);
ytneg=yt*-1; %generatingg bottom half of airfoil
yfull= [yt ytneg]; % full points for y axis of airfoil
y=yfull';
x2=flipud(x);
xfull=[x x2];%full points for x axis of airfoil
x=xfull';
TR=delaunayTriangulation(x,y); %triangulation of the airfoil
triplot(TR,x,y) %plotting the triangulation

 Accepted Answer

You can access x,y coordinates of each triangle like below:
nodes = TR.ConnectivityList ; % nodal connectivity matrix
coor = TR.Points ; % coordinates
ntri = size(nodes,1) ; % number of triangles
% loop for each triangle
for i = 1:ntri
xi = coor(nodes(i,:),1) ; % x coordinates of i'th rriangle
yi = coor(nodes(i,:),2) ; % y coordinates of i'th triangle
% do what you want
end
But let me tell you, your mesh of air foil is very bad. I suggest you to go through the following meshing package: https://in.mathworks.com/matlabcentral/fileexchange/25555-mesh2d-automatic-mesh-generation

4 Comments

I've been trying to use the Mesh2d package you recommended. I get the following error:
Undefined function or variable 'tsearch'.
Error in meshfaces>boundarynodes (line 199) i = tsearch(ph(:,1),ph(:,2),th,p(:,1),p(:,2));
Error in meshfaces (line 140) pbnd = boundarynodes(qtree.p,qtree.t,qtree.h,node,edge,options.output);
Error in mesh2d (line 102) [p,t,junk,stats] = meshfaces(node,edge,[],hdata,options);
KSSV
KSSV on 26 Dec 2016
Edited: KSSV on 26 Dec 2016
that is a version problem...the same error is discussed there in the link, you can correct it.
yeah that was me who posted. unfortunately I'm not good enough at matlab to do so.
tsearch problem, can be sorted by minor editing the code. I have done it very long ago, if I get time I will check it. Mean while go through the above link.

Sign in to comment.

More Answers (0)

Categories

Asked:

on 21 Dec 2016

Commented:

on 28 Dec 2016

Community Treasure Hunt

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

Start Hunting!