calculate the area of the surface formed by the points having coordinates [xd, yd]??

first,i used 'polybool' to determine the overlap between plusieurs ellipses
i=1;
while i<n
for j=i+1:n
t=(0:pi/20:2*pi);
x1=G(i,3)*cos(t);
y1=G(i,4)*sin(t);
x2=G(j,3)*cos(t);
y2=G(j,4)*sin(t);
[xd, yd] = polybool('intesection', x1, y1, x2, y2,'vector');
end
i=i+1;
end
now i want to calculate the area of the surface formed by the points having coordinates [xd, yd],how can i do it??

 Accepted Answer

Hi,
you could do a Delauny Triangulation using the delaunay function and then calculate and sum up the area of each triangle. This should work as long your surface is one connected area. Or in the case the area of the convex hull is okay for your use polyarea.

6 Comments

Hi i made a Delauny Triangulation as you said,then i would like to calculate the area of each triangle,and calculate the sum of all the triangles,my broblem is that the funtion delauny returns a 3_by_m matrix each row contain one triangle,but the polybool(x,y)need two parametres, this is the code
if true
%%intersectaire
t=(0:pi/20:2*pi);
x1=a*cos(t);
y1=b*sin(t);
x2=a*cos(t);
y2=b*sin(t);
[xd, yd] = polybool('intersection', x1, y1, x2, y2);%donner les points appartenent à la fois à xi et xj
tri = delaunay(xd,yd);%returns a set of triangles such that no data points Each row of the numt-by-3 matrix TRI defines one such triangle and contains indices into the
areaintersect=0;
k=1;
while k< 50000
for m=1:3
areatriang=ones(5000,3);
areatriang=polyarea(?,?);%calculer l'aire de chaque triangle
areaintersect= areaintersect+areatriang;%retourne somme des aires se triang de delaunay et donner l'aire d'intersection
k=k+1;
end
end
end
would you plz tell me how to fix it?
Hi,
the matrix TRI contains the indices which make up the triangles. So each row is one triangle. So Triangle i is defined by the 3 points:
xd(tri(i,1)) yd(tri(i,1))
xd(tri(i,2)) yd(tri(i,2))
xd(tri(i,3)) yd(tri(i,3))
And you would need to calaculte the area of those, e.g. by using polyarea.
sorry but i can't get it well,then every row describe one triangle,then how come tri(i,1) has two significant xd and yd? what i get it that evry row contins 3 numbers and not 6 ??
The triangles are build from the points you provide to the delauny function. The numbers it contains are the indices in xd/yd used to create a triagle. Since a triangle has 3 corner points you have 3 indices in TRI and the indices are the same for xd and yd (thats why you have 3 values instead of 6). Maybe use triplot to see how the triangulation looks to get a better feeling for it. After delauny was called use:
triplot(tri,xd,yd)
hold on
plot(xd,yd,'r*')
hold off
From what I can see it seems like your area is convex anyway so you might can call polyare directly with xd and yd instead of doing the triangulation.
So as example
a= 1;
b = 2;
t=(0:pi/20:2*pi);
x1=a*cos(t);
y1=b*sin(t);
x2=a*cos(t);
y2=b*sin(t);
[xd, yd] = polybool('intersection', x1, y1, x2, y2);%donner les points appartenent à la fois à xi et xj
pa = polyarea(xd,yd)
%used triangulation
tri = delaunay(xd,yd);%returns a set of triangles such that no data points Each row of the numt-by-3 matrix TRI defines one such triangle and contains indices into the
areaintersect=0;
for i=1:size(tri,1)
areaintersect = areaintersect + polyarea([xd(tri(i,1)),xd(tri(i,2)),xd(tri(i,3))], [yd(tri(i,1)),yd(tri(i,2)),yd(tri(i,3))] );
end
areaintersect
thank you very much,it's really very helpful
Please accept an answer if it helped you.

Sign in to comment.

More Answers (0)

Categories

Tags

Community Treasure Hunt

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

Start Hunting!