سؤال

How to split one big rectangle on N smaller rectangles to look random ? I need to generate couple divisions for different value of n. Is there library for this in boost for c++ or some for python ?

هل كانت مفيدة؟

المحلول

One rectangle can be divided into two rectangles by drawing either a horizontal or a vertical line. Divide one of those rectangles and the result is three rectangles. Continue until you have N rectangles. Some limitations to observe to improve the results

  • Don't divide a rectangle with a horizontal line if the height is below some threshold
  • Don't divide a rectangle with a vertical line if the width is below some threshold
  • Divide by quarters, thirds, or halves, i.e. avoid 90/10 splits
  • Keep a list of rectangles sorted by area, and always divide the rectangle with the largest area
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top