two polygon difference

Hello all,
i have two polygons which are intersecting. i know the vertex and intersection points of polygons. i want to get the difference area. if i knew how to difference two polygon, it was so easy but i could not. two polyogns vertex and interseciton points as below
[[0.7;4.5;8;2.9],[3.7;0.5;3.2;7.3]]
[[1;6;6;1],[1;1;6;6]]
intersection points
1.0000 4.1909
1.0000 3.4474
3.9063 1.0000
5.1481 1.0000
6.0000 1.6571
6.0000 4.8078
4.5171 6.0000
2.1056 6.0000
the polygons are as in the pict.
i would be greatfull, if you could help me. thank you in advance.

Answers (2)

the cyclist
the cyclist on 22 May 2012

0 votes

I am not perfectly clear what you mean by "difference area". However, I expect that you can calculate what you want using the polyarea() command.
If you put in the x and y column vectors of the intersection points, that will calculate the area of the polygon defined by the intersection. You can then presumably calculate any differences you need by using polyarea() again on the individual polygons.

4 Comments

dediydi
dediydi on 22 May 2012
thanks you but i am not interesetted in area value. i just want to get the points of difference triangle's vertex points. maybe this picture tells more than i say
http://img42.imageshack.us/img42/1340/polygon2q.jpg
The area of you want is the difference of two areas that each can be determined with polyarea():
(1) Area of irregular polygon
(2) Area of intersection
dediydi
dediydi on 22 May 2012
http://img140.imageshack.us/img140/1773/pol4m.jpg
OK. If I were to ignore everything that has been said in this thread, and ONLY saw this figure, I would say that you should patch the rectangle the color you want, followed by patching the "top" figure white again. You know all the vertices, so that should be easy.
But, every time I think I have a solution, it seems I still don't understand what you are really trying to do.

Sign in to comment.

Notice that vertices of the intersection points are not members of the convex hull of the two polygons. Also, notice that they are vertices of the convex hull of the intersected part of the two polygons. Using these two pieces of information, you should be able to generate the intersected polygon. From this information, you can either use the surveyor's formula (i.e. polyarea()) or you could skip this and use the second output from the convex hull calculation.
doc convhull

8 Comments

dediydi
dediydi on 22 May 2012
Thank you Sean but as i said cyclist i dont want to calculate the intersection area. i have already done it . now i want to get the other part of the clipped polygon which is drawn blue in the picture, that is i want to difference polygon now. i am sure this picture tell more.
http://img42.imageshack.us/img42/1340/polygon2q.jpg
i want to get the point in circle.
You want to calculate the total area of the blue? Or four separate area calculations? Or something else?
dediydi
dediydi on 22 May 2012
there are four sparete areas, that is four triangles. i want to calculate these triagnle's vertex points.
dediydi
dediydi on 22 May 2012
this could explain more. http://img140.imageshack.us/img140/1773/pol4m.jpg
So subtract the area of intersecting region (found above) from the area of the single polygon?
@dediydi, I think Sean and I are both still a bit perplexed as to the goal. Is your primary goal to CALCULATE something, to DRAW something, or both?
Geoff
Geoff on 23 May 2012
This is fun. I get the feeling that you don't realise the area that remains after removing the intersecting polygon (ie your difference area) is exactly the area of the original polygon minus the area of the intersection, as Sean said. If you do realise that and it's not what you want, could it be that you want to calculate the area of the remaining polygon(s) individually? That would be a little trickier, cos you'd need to detect which parts of the polygon have been separated from the rest by seeing which edges have been bisected.
@Geoff: That would be a fun problem. It sounds like a good one for CODY.

Sign in to comment.

Categories

Asked:

on 22 May 2012

Community Treasure Hunt

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

Start Hunting!