Calculating the intersection area of two polygons

Started by
7 comments, last by NMO 17 years, 1 month ago
Hi! As the subject says, I have two abitrary polygons which are intersecting. Both are coplanar too. Now I want to calculate the intersection area of these two polygons. Are there any good approaches for this problem??
Advertisement
This is a difficult problem. The easier way to solve it is using a third-party library. I have used the GPC library before, and I was satisfied.

Thank you for your answer, but is it really as complicated? I would really like to implement my own version. I don't have complicated things like self-intersecting or holes. Aren't there any good approaches??

The only simple, robust approach I can think of is expressing each polygon as a union of convex polygons, computing the intersections of the convex polygons and putting the results back together. Even this is harder than it looks.

Maybe i have found a sultion. When there is an intersection between two polys, at first i compute the intersection polygon(s). The hard thing is to compute the area
of these intersection polygons. To do this I have found an area calculation algorithm according to Gauß. I have tried some examples an all of them worked properly. :)
Computing the area of an arbitrary polygon is a relatively trivial problem. Calculating the intersection of two arbitrary polygons in a robust manner is much much harder. How do you intend to do that part?
Quote:Computing the area of an arbitrary polygon is a relatively trivial problem.


Yes okay, but that was the main problem.

Quote:Calculating the intersection of two arbitrary polygons in a robust manner is much much harder. How do you intend to do that part?


I did that already:

Click

And then to calculate the area of this intersecting polygon, I use a Gauß algorithm as mentioned before.
Area = .5 * abs(x[0]*y[1]-x[1]*y[0] + x[1]*y[2]-x[2]*y[1] + ... + x[n-1]*y[0]-x[0]*y[n-1])


Is that what Gauss said?
Yes looks good.

This topic is closed to new replies.

Advertisement