Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

RectanglePacking

Guides

  • Rectangle Packing

Symbols

  • PackRectangles
  • RectanglePacker
JasonB`RectanglePacking`
RectanglePacker
​
RectanglePacker
[boundingbox]
creates a mutable data structure into which rectangles can be packed.
​
​
RectanglePacker
[boundingbox,method]
uses the given
method
to pack rectangles.
​
Details and Options

Examples  
(3)
Basic Examples  
(1)
Create a mutable rectangle packing data structure:
In[1]:=
rectp=
RectanglePacker
[{200,100}]
Out[1]=
RectanglePacker

Dimensions:
{200,100}
Occupancy:
0.
Packed:
0
Method:
MaxRectangles
AllowFlips:
True
FreeChoiceHeuristic:
BestAreaFit

Insert some rectangles:
In[2]:=
rectp["Insert",RandomInteger[{4,18},{60,2}]]//Short
Out[2]//Short=
{{{31,0},{43,14}},{{43,24},{57,29}},57,{{55,92},{64,98}}}
Visualize the state of the packing object:
In[3]:=
rectp["Graphics"]
Out[3]=
Add a fixed rectangle:
In[4]:=
rectp["PlaceRectangle",Rectangle[{120,20},{150,90}]]​​rectp
Out[4]=
RectanglePacker

Dimensions:
{200,100}
Occupancy:
0.466
Packed:
61
Method:
MaxRectangles
AllowFlips:
True
FreeChoiceHeuristic:
BestAreaFit

Add more rectangles:
In[5]:=
rectp["Insert",RandomInteger[{4,18},{60,2}]];​​rectp["Graphics"]
Out[5]=
Try to insert a rectangle that is too large to fit in the remaining space:
In[6]:=
rectp["Insert",{50,50}]
PackRectangles
::nopac
:Failed to pack 1 rectangles.
​
Out[6]=
Failure

Input: {50,50}
Tag: UnplacedRectangle

Scope  
(1)

Interactive Examples  
(1)

SeeAlso
PackRectangles
 
▪
Rectangle
RelatedGuides
▪
Rectangle Packing
RelatedLinks
RectangleBinPack library,
▪
https://github.com/juj/RectangleBinPack
A thousand ways to pack the bin-a practical approach to two-dimensional rectangle bin packing. Jukka Jylänki. 2010.
▪
[more info]
""

© 2025 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com