two polygon difference

조회 수: 5 (최근 30일)
dediydi
dediydi 2012년 5월 22일
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.

답변 (2개)

the cyclist
the cyclist 2012년 5월 22일
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
dediydi
dediydi 2012년 5월 22일
http://img140.imageshack.us/img140/1773/pol4m.jpg
the cyclist
the cyclist 2012년 5월 22일
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.

댓글을 달려면 로그인하십시오.


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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Bounding Regions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by