Boxes with small areas perform worse than larger boxes
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 355
- Forks
- 24
- PR merge metrics
- No merged PRs in 30d
Description
When preparing box-areas for a custom uv-unwrapping algorithm, I end up with small boxes that combined together will fit a total area around 1 unit large, e.g.:
```javascript
[
{ w: 0.05, h: 0.037 },
{ w: 0.015, h: 0.0087 },
{ w: 0.009, h: 0.013 },
...
]
```
when packing these boxes potpack will perform poorly, by laying the boxes mostly horizontally:
However pre-processing my boxes such that they're scaled up by a factor of 100+, will improve results dramatically:
```javascript
const boxScale = 200;
rects = rects.map(r => ({ w: r.w * boxScale, h: r.h * boxScale }));
const res = potpack(rects);
rects = rects.map(r => ({ w: r.w / boxScale, h: r.h / boxScale, x: r.x / boxScale, y: r.y / boxScale }));
```
In case this is expected behavior, it would be nice if the documentation reflected this edge case since someone else might incorrectly assume that the algorithm doesn't work when in reality scaling up the boxes might fix the issue
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported behavior through the potpack(rects) entry point with the small box values shown, then compare it with the same boxes scaled by 200 and scaled back afterward. Determine whether the difference is expected or a defect; done means either documenting the scaling workaround and edge case or providing a verified correction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100