bbox = Bbox(ll, ur) transform = get_bbox_transform(unit_bbox(), bbox) assert( closeto_seq( inverse_transform_bbox(transform, bbox).get_bounds(), (0,0,1,1))) assert( closeto_seq( transform_bbox(transform, unit_bbox()).get_bounds(), (-10,-10,210,50))) # test the bbox all bounding functions boxes = [rand_bbox() for i in range(20)] xmin = min([box.xmin() for box in boxes]) xmax = max([box.xmax() for box in boxes]) ymin = min([box.ymin() for box in boxes]) ymax = max([box.ymax() for box in boxes]) box = bbox_all(boxes) assert( closeto_seq( box.get_bounds(), (xmin, ymin, xmax-xmin, ymax-ymin))) t1 = rand_transform() oboundsx = t1.get_bbox1().intervalx().get_bounds() oboundsy = t1.get_bbox1().intervaly().get_bounds() t2 = copy_bbox_transform(t1) t1.get_bbox1().intervalx().set_bounds(1,2) t2.get_bbox2().intervaly().set_bounds(-1,12) newboundsx = t2.get_bbox1().intervalx().get_bounds() newboundsy = t2.get_bbox1().intervaly().get_bounds() assert(oboundsx==newboundsx) assert(oboundsy==newboundsy)
ur = Point(Value(200), Value(40)) bbox = Bbox(ll, ur) transform = get_bbox_transform(unit_bbox(), bbox) assert (closeto_seq( inverse_transform_bbox(transform, bbox).get_bounds(), (0, 0, 1, 1))) assert (closeto_seq( transform_bbox(transform, unit_bbox()).get_bounds(), (-10, -10, 210, 50))) # test the bbox all bounding functions boxes = [rand_bbox() for i in range(20)] xmin = min([box.xmin() for box in boxes]) xmax = max([box.xmax() for box in boxes]) ymin = min([box.ymin() for box in boxes]) ymax = max([box.ymax() for box in boxes]) box = bbox_all(boxes) assert (closeto_seq(box.get_bounds(), (xmin, ymin, xmax - xmin, ymax - ymin))) t1 = rand_transform() oboundsx = t1.get_bbox1().intervalx().get_bounds() oboundsy = t1.get_bbox1().intervaly().get_bounds() t2 = copy_bbox_transform(t1) t1.get_bbox1().intervalx().set_bounds(1, 2) t2.get_bbox2().intervaly().set_bounds(-1, 12) newboundsx = t2.get_bbox1().intervalx().get_bounds() newboundsy = t2.get_bbox1().intervaly().get_bounds() assert (oboundsx == newboundsx) assert (oboundsy == newboundsy) import math