#math #vector #vector2 #vector3 #gamedev

fixed-vectors

Library implementing fixed-length Vectors meant for representing dimensional values

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

Download history 1/week @ 2022-12-02 31/week @ 2022-12-09 1/week @ 2022-12-23 1/week @ 2022-12-30 1/week @ 2023-01-06 5/week @ 2023-01-13 3/week @ 2023-01-20 10/week @ 2023-01-27 67/week @ 2023-02-10 72/week @ 2023-02-17 38/week @ 2023-02-24 22/week @ 2023-03-10 2/week @ 2023-03-17

62 downloads per month

MIT license

31KB
434 lines

fixed-vectors

GitHub - Publish Status Docs.rs - Latest Crates.io - Downloads Crates.io - Version Crates.io - License

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