0

Say I have a number of 2D boxes, I know all their dimensions, I need to place them randomly in a larger 2D box without them overlapping. The total area of the larger box is equal to or greater than the combined area of all the smaller boxes. What's the best way to randomly place the smaller boxes and check there's no overlap, without doing something like running the random placement function in a while loop until there's no overlap, because that could take a while or cause an infinite loop.

Ali
  • 56,466
  • 29
  • 168
  • 265
  • 1
    http://en.wikipedia.org/wiki/Packing_problem ? – Ali Jul 04 '13 at 10:12
  • The question has nothing to do with design patterns IMO. – Ali Jul 04 '13 at 10:13
  • What's the question? How to place them without overlap (title), or how to randomly place them an determine whether there is overlap (body)? – tobias_k Jul 04 '13 at 10:29
  • sorry wasnt sure what to tag it. It's about how to place randomly (or at least seemingly randomly) without overlap in a defined area – user2549862 Jul 04 '13 at 11:27
  • [This](https://stackoverflow.com/questions/63707669/trying-to-create-x-number-of-random-rectangles-by-iterating-through-loop-but-n) might be of interest to you. – Different Gravity Sep 04 '20 at 08:51

0 Answers0