主席:沼气泄漏了# Joke - 肚皮舞运动
l*8
1 楼
A 2-D bounding box can represented as (Xmin, Xmax, Ymin, Ymax). We have a
set of bounding boxes. There is no intersection between any two of the
bounding boxes.
Now we want to insert one bounding box into the bounding boxes set and merge
the intersected bounding boxes if necessary. Two intersected boxes can be
merged into a big box like this:
Xmin = min(Xmin1, Xmin2); Xmax = max(Xmax1, Xmax2);
Ymin = min(Ymin1, Ymin2); Ymax = max(Ymax1, Ymax2);
Design an algorithm to do the insertion.
Example:
Exising bounding boxes set is { (1,4,0,2), (0,2,3,6) }
Bounding box to be inserted: (3,5,1,4)
Result: { (0, 5, 0, 6) }
set of bounding boxes. There is no intersection between any two of the
bounding boxes.
Now we want to insert one bounding box into the bounding boxes set and merge
the intersected bounding boxes if necessary. Two intersected boxes can be
merged into a big box like this:
Xmin = min(Xmin1, Xmin2); Xmax = max(Xmax1, Xmax2);
Ymin = min(Ymin1, Ymin2); Ymax = max(Ymax1, Ymax2);
Design an algorithm to do the insertion.
Example:
Exising bounding boxes set is { (1,4,0,2), (0,2,3,6) }
Bounding box to be inserted: (3,5,1,4)
Result: { (0, 5, 0, 6) }