When you specify max_width and max_height and the values are small enough that the algorithm can't build it's preferred shape, the (x, y) values of the resulting positions are switched. If max_width and max_height are big enough so that the algo can build it's preferred shape, all is fine.
import rpack
sizes = [(2736, 3648), (2736, 3648), (3648, 2736), (2736, 3648), (2736, 3648)]
# Max width/height big enough that the algorithm can build its preferred shape:
max_wh = 70650
positions = rpack.pack(sizes, max_width=max_wh, max_height=max_wh)
print(positions) # [(0, 0), (2736, 0), (10944, 0), (5472, 0), (8208, 0)]
print(rpack.overlapping(sizes, positions)) # None
# Max width/height smaller so that the algorithm need to deviate from its preferred shape:
max_wh = 14130
positions = rpack.pack(sizes, max_width=max_wh, max_height=max_wh)
print(positions) # [(0, 0), (0, 2736), (3648, 0), (0, 5472), (0, 8208)]
print(rpack.overlapping(sizes, positions)) # (0, 1)
print(rpack.overlapping(sizes, [(p[1], p[0]) for p in positions])) # None
max_wh = 8478
positions = rpack.pack(sizes, max_width=max_wh, max_height=max_wh)
print(positions) # [(0, 0), (0, 2736), (3648, 2736), (0, 5472), (3648, 0)]
print(rpack.overlapping(sizes, positions)) # (0, 1)
print(rpack.overlapping(sizes, [(p[1], p[0]) for p in positions])) # None
There's an easy workaround, if anyone needs this, just apply this to your resulting positions:
if rpack.overlapping(sizes, positions):
positions = [(p[1], p[0]) for p in positions]
When you specify max_width and max_height and the values are small enough that the algorithm can't build it's preferred shape, the (x, y) values of the resulting positions are switched. If max_width and max_height are big enough so that the algo can build it's preferred shape, all is fine.
There's an easy workaround, if anyone needs this, just apply this to your resulting positions:
With this, all works like a charm.