# Find a minimal box to fit 10 random rectangles.
# Search for boxes with aspect ratios in seq(0.5, 2, length.out = 20)
set.seed(2)
N <- 10
rect_widths <- sample(N)
rect_heights <- sample(N)
box <- calc_small_box(rect_widths, rect_heights,
aspect_ratios = seq(0.5, 2, length.out = 20))
box
rects <- pack_rects(box$width, box$height, rect_widths, rect_heights)
all(rects$packed)
Run the code above in your browser using DataLab