I have a polygon that is in a 2D grid:
(let's assume that I can draw a grid where the distances between each line are the same)

Now I'm looking for an algorithm or some kind of implementation that could cut a polygon into several smaller polygons along the grid.
Sample C ++ code that basically shows what I want to do:
struct Point2D { double x; double y; } struct Polygon { std::vector<Point2D> points; } std::vector<Polygon> getSubpolygons( Polygon givenPolygon, double gridSize ) { Code here... }
Are there any algorithms or implemented libraries that could do this?
MOnsDaR
source share