30 stable releases
2.0.5 | Aug 28, 2022 |
---|---|
2.0.4 | Aug 26, 2022 |
1.8.4 | Apr 21, 2022 |
1.7.0 | Feb 7, 2022 |
1.6.1 | Jan 31, 2022 |
#433 in Data structures
62 downloads per month
31KB
434 lines
fixed-vectors
Library implementing fixed-length vectors meant for representing positional and dimensional values. These vectors have various mathematical and helper functions implemented for them out of the box for ease of use in calculations, especially game development related ones. These methods are all implemented using the impl_vector!
macro.
Example
use fixed_vectors::Vector2;
use std::convert::TryFrom;
let str_vec = Vector2::new("Hello", "World");
assert_eq!(str_vec.to_tuple(), ("Hello", "World"));
let mut num_vec = Vector2::new(1.0, 2.0);
num_vec += Vector2::new(0.4, 0.9);
assert_eq!(num_vec.round(), Vector2::new(1.0, 3.0));
if let Ok(from_vec_vec) = Vector2::try_from(vec![4, 2]) {
assert_eq!(from_vec_vec, Vector2::new(4, 2));
}
Dependencies
~150KB