Reputation: 197
I'm trying to create a Java method that receives two polygons as parameters and returns a third polygon that represents the portion of Polygon A that is not intersected by Polygon B. Here's a visual.
https://i.sstatic.net/gSAEH.png
Polygon A is the black polygon, Polygon B is the green polygon intersecting Polygon A, and the return Polygon is the blue shaded region within Polygon A.
Upvotes: 0
Views: 73
Reputation: 80187
You need algorithms or library for boolean operations on polygons. Your example shows concave polygon, so you can use Vatti or Greiner-Hofmann algorithm.
I suspect that proper implementation of these methods is rather complex, so recommend to choose ready-to-use library, for example, from this page/software (I don't see Java support claimed except for this one, but check for possibilities)
Upvotes: 1