rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
get_triangle_midpoints.m
Go to the documentation of this file.
1 function midpoints = get_triangle_midpoints(p,t)
2 %computes triangle midpoints for given mesh data
3 
4 ntria = size(t,2); %nof triangles
5 
6 tp=t(1:3,:); %indices of all triangles
7 tp(:);
8 
9 %x
10 px=p(1,tp); %corresponding x values
11 
12 px=reshape(px,3,ntria); %corr. x values sorted
13 
14 cx=mean(px)';
15 
16 %y
17 py=p(2,tp);
18 
19 py=reshape(py,3,ntria);
20 
21 cy=mean(py)';
22 
23 midpoints=[cx,cy];
24 
25 
26 
27 
28 
function midpoints = get_triangle_midpoints(p, t)
computes triangle midpoints for given mesh data