说,我想从一块矩形板上刮掉一些矩形孔。例如,
情况1、孔相交:
一个带有孔 0,1,2 的 borad x,矩形 0 和 1 相交。
xxxxxxxxxxx
xxxxxx222xx
x000xx222xx
x00011222xx
x00011xxxxx
xxx111xxxxx
xxxxxxxxxxx
或更简单,情况2,没有孔相交:
xxxxxxxxxxx
xxxxx2222xx
x00xx2222xx
x00xx2222xx
x00x111xxxx
xxxx111xxxx
xxxxxxxxxxx
后者更像是“在一个大矩形内反转一组矩形”。
我的问题是:如何计算一组完全覆盖板 x 的子矩形?
Input: a larger rect, and a set of hole rects
Output: a set of sub rects cover exactly the larger rect with holes
rect 结构可能像下面的 CCRect,协调类型是浮点数:
typedef struct {float x; float y;} CGPoint;
typedef struct {float width, float height} CGSize;
typedef struct {CGPoint origin; CGSize size;} CGRect;
有什么好主意吗?