Skip to content

OliverEvans96/BinaryTreeRectanglePacking.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BinaryTreeRectanglePacking.jl

Fit as many rectangles as possible into a container using binary trees in Julia.

Works in N dimensions.

Packing algorithm inspired by this blog post, binary tree struct implementation inspired by AbstractTrees.jl examples

PRs/suggestions welcome!

Instructions

The main packing function has the signature:

function pack(
    container_dims::NTuple{N,<:Real},
    rect_dims::Vector{NTuple{N,T}},
)::Vector{Union{NTuple{N,Float64},Nothing}} where {T<:Real} where {N}

Give it the dimensions of your container and (pre-sorted) rectangles. It will return a vector with an entry for each rectangle, either NTuple{N, Float64} if it was packed successfully, or nothing if it couldn't fit.

Examples

fig1

fig2

fig3

About

Fit as many rectangles as possible into a container using binary trees in Julia

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages