Fit elements into box

2019-08-23 02:39发布

问题:

I want to achieve the effect shown in the images attached. Given certain items, fit them into a shape (box or something else), with the option to resize the items or not.

I know there has to be some algorithm related, but I don't know where to start looking.

Any keyword, wikipedia article, or pdf will be welcome.

回答1:

The problem, as NKamrath pointed out, was Bin packing problem, but more commonly refered to Texture Packing. Here are the resources I gathered:

  • http://en.wikipedia.org/wiki/Bin_packing_problem
  • http://www.blackpawn.com/texts/lightmaps/default.html
  • http://www.gamedev.net/topic/392413-rectangle-packing/
  • http://clb.demon.fi/projects/rectangle-bin-packing
  • http://clb.demon.fi/projects/more-rectangle-bin-packing
  • http://clb.demon.fi/files/RectangleBinPack.pdf