two polygon difference

1 view (last 30 days)
dediydi
dediydi on 22 May 2012
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
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
http://img140.imageshack.us/img140/1773/pol4m.jpg
the cyclist
the cyclist on 22 May 2012
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.


Sean de Wolski
Sean de Wolski on 22 May 2012
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
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.
Sean de Wolski
Sean de Wolski on 23 May 2012
@Geoff: That would be a fun problem. It sounds like a good one for CODY.

Sign in to comment.

Categories

Find more on Bounding Regions in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!