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`
PackRectangles
​
PackRectangles
[boundingbox,{
rect
1
,
rect
2
,..}]
packs the given
rectangles
in the given bounding box.
​
​
PackRectangles
[boundingbox,rectangles,method]
uses the given
method
to pack
rectangles
.
​
Details and Options

Examples  
(2)
Basic Examples  
(1)
Pack a sequence of squares into a larger square:
In[1]:=
PackRectangles
[{100,100},Table[{n,n},{n,30}]]
Out[1]=
{{{13,99},{14,100}},{{25,98},{27,100}},{{54,96},{57,99}},{{50,96},{54,100}},{{30,25},{35,30}},{{91,87},{97,93}},{{91,80},{98,87}},{{90,72},{98,80}},{{90,63},{99,72}},{{50,86},{60,96}},{{25,87},{36,98}},{{13,87},{25,99}},{{0,87},{13,100}},{{36,86},{50,100}},{{76,83},{91,98}},{{60,84},{76,100}},{{73,66},{90,83}},{{55,66},{73,84}},{{55,47},{74,66}},{{79,21},{99,41}},{{79,0},{100,21}},{{78,41},{100,63}},{{55,24},{78,47}},{{55,0},{79,24}},{{30,0},{55,25}},{{29,30},{55,56}},{{28,59},{55,86}},{{0,59},{28,87}},{{0,30},{29,59}},{{0,0},{30,30}}}
In[2]:=
$RectanglePackingMethods
Out[2]=
{MaxRects,Guillotine,Shelf,Skyline,MaxRectsBestShortSide,MaxRectsBestLongSide,MaxRectsBestArea,MaxRectsBottomLeft,MaxRectsContactPoint,GuillotineBestShortSide,GuillotineBestLongSide,GuillotineBestArea,GuillotineWorstShortSide,GuillotineWorstLongSide,GuillotineWorstArea,ShelfNextFit,ShelfFirstFit,ShelfBestAreaFit,ShelfBestHeightFit,ShelfBestWidthFit,ShelfWorstAreaFit,ShelfWorstWidthFit,SkylineBottomLeft,SkylineBestFit}
Visualize the result:
In[3]:=
Graphics[{EdgeForm[Black],FaceForm[None],Rectangle@@@%},FrameTrue]
Out[3]=
Options  
(1)

SeeAlso
RelatedGuides
▪
Rectangle Packing
""

© 2025 Wolfram. All rights reserved.

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