modulitos / bin_packer_3d Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Some possible options:
Possible resource:
https://www.lpalmieri.com/posts/2020-06-06-zero-to-production-1-setup-toolchain-ides-ci/#5-continuous-integration
We wanted to support floats as dimensions, but I couldn't figure out an easy way to do without aliasing our Dimension
type to f32
: pub type Dimension = f32;
. Doing that forces us to always use floats as argument constructors, even in the case where an int is preferable:
let deck = Item::new("deck", [2.0, 8.0, 12.0]);
let die = Item::new("die", [8.0, 8.0, 8.0]);
let items = vec![deck.clone(), deck.clone(), die, deck.clone(), deck];
let packed_items = packing_algorithm(Bin::new([8.0, 8.0, 12.0]), &items);
I think the desired use case is to have the ability to support ints as well as floats:
let item_1 = Item::new("deck", [2, 8, 12]);
let item_2 = Item::new("deck", [2.25, 8.34, 12.65]);
But I'm not sure about the best way to do this. Perhaps we should leverage this crate: https://docs.rs/rust_decimal/1.0.1/rust_decimal/ ? Or maybe roll our own implementation?
If using our own implementation, one idea is to create a new struct with a fixed precision of 2 decimal places:
struct Dimension {
whole_number: u8, // 0-255
decimal: u8, // max value of 99
}
This would give our dimensions a range of 0.00 to 255.99, and should be easy extend this further as needed. However, in order to support the current new
function:
https://github.com/modulitos/bin_packer_3d/blob/master/src/block.rs#L28-L32
pub fn new(d1: Dimension, d2: Dimension, d3: Dimension) -> Self {
we'll need to convert the integers and floats into our new Dimension
struct. Perhaps we can have Dimension
implement the From (or Into) traits:
impl From<u8> for Dimension {...}
impl From<f32> for Dimension {...}
But I'm not sure if this is the right approach - does this seem reasonable? Any feedback here would be appreciated ๐
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.