two polygon difference

2 Ansichten (letzte 30 Tage)
dediydi
dediydi am 22 Mai 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.

Antworten (2)

the cyclist
the cyclist am 22 Mai 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 Kommentare
dediydi
dediydi am 22 Mai 2012
http://img140.imageshack.us/img140/1773/pol4m.jpg
the cyclist
the cyclist am 22 Mai 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.

Melden Sie sich an, um zu kommentieren.


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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Bounding Regions finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by