我有一个位于二维网格中的多边形:(
假设我能够绘制每条线之间的距离相同的网格)
我现在正在寻找一种算法或某种实现,可以将多边形沿着网格切割成几个较小的多边形。
C ++中的一些示例代码基本上显示了我想要做的事情:
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...
}
是否有任何算法或实现的库可以做到这一点?