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!
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.