Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimum bin size by volume #16

Open
seanonthenet opened this issue Aug 21, 2020 · 3 comments
Open

Minimum bin size by volume #16

seanonthenet opened this issue Aug 21, 2020 · 3 comments

Comments

@seanonthenet
Copy link
Contributor

Hi there.

Is this able to return a minimum 3D bin size by volume given a set of supplied items?

Example use case: a custom box will be made up for the items for each shipment.

Thanks
Sean

@superdav42
Copy link
Contributor

superdav42 commented Feb 26, 2021

There's not a built in method for this but the calculation should be pretty simple:

        let packer = new Packer();
        packer.addItem(new Item("Item 1", 100, 100, 100, 100));
        packer.addItem(new Item("Item 2", 100, 100, 100, 100));
        packer.addItem(new Item("Item 3", 100, 100, 100, 100));
        const totalVolume = packer.items.reduce( ( vol, item ) => vol + item.getVolume(), 0 );

@seanonthenet
Copy link
Contributor Author

seanonthenet commented Mar 7, 2021

Thanks very much.

For anyone else... to "unfactor precision" 🤷‍♂️ the result you can do this. There's probably a more elegant way. Sorry, I'm not a math guy.

let packer = new Packer();
let FACTOR = 5
packer.addItem(new Item("Item 1", 100, 100, 100, 100));
packer.addItem(new Item("Item 2", 100, 100, 100, 100));
packer.addItem(new Item("Item 3", 100, 100, 100, 100));
const totalVolume = packer.items.reduce( ( vol, item ) => vol + item.getVolume() / (10 ** FACTOR) ** 3 );

@seanonthenet
Copy link
Contributor Author

Is this solution though just returning the sum of the volumes of Items in a Packer?

If so it doesn't really find the minimum box size that could fit them all taking into account empty space, pivots etc.

Am I right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants