+ibbox_t ibbox_clip(ibbox_t* outer, ibbox_t* inner)
+{
+ ibbox_t i = {inner->xmin, inner->ymin, inner->xmax, inner->ymax, 0};
+ if(i.xmax > outer->xmax) i.xmax = outer->xmax;
+ if(i.ymax > outer->ymax) i.ymax = outer->ymax;
+ if(i.xmax < outer->xmin) i.xmax = outer->xmin;
+ if(i.ymax < outer->ymin) i.ymax = outer->ymin;
+
+ if(i.xmin > outer->xmax) i.xmin = outer->xmax;
+ if(i.ymin > outer->ymax) i.ymin = outer->ymax;
+ if(i.xmin < outer->xmin) i.xmin = outer->xmin;
+ if(i.ymin < outer->ymin) i.ymin = outer->ymin;
+ return i;
+}
+