문제

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