Terry T
Terry T

Reputation: 119

Finding and representing area between nested, non-intersecting polygons

Given two java.awt.Polygon objects p1 and p2, how would I go about determining (and representing) the area between them?

sample image

I would like to find the gray area within in-between the polygons. The polygons are arbitrary and the only information I have about them are their points (x,y).

The answer might be staring right at me but I've been trying to come up with a solution for >2 hours in vain now so any and all pointers will be much appreciated!

Edit: the first thing I tried was representing both polygons as one but that resulted in an unusable mess of intersections.

Upvotes: 0

Views: 111

Answers (1)

Joe C
Joe C

Reputation: 15684

You can convert both of these polygons into Areas, and then do a subtract from there.

Upvotes: 2

Related Questions