I have a polygon which is located in a 2D grid:
(lets assume I'm able to paint a grid where the distances between each line is the same)
I'm now searching for an algorithm or some sort of implementation which could cut the polygon into several smaller polygons along the grid.
Some example code in C++ which basically shows what I want to do:
struct Point2D
{
double x;
double y;
}
struct Polygon
{
std::vector<Point2D> points;
}
/**
* givenPolygon is the 'big' polygon which should be divided
* gridSize is the distance between the gridlines
* return value is a vector of the resulting subpolygons
*/
std::vector<Polygon> getSubpolygons( Polygon givenPolygon, double gridSize )
{
Code here...
}
Are there any algorithms or implemented libraries which could do that?