| Crates.io | tiny_vect |
| lib.rs | tiny_vect |
| version | 0.1.3 |
| created_at | 2025-07-21 01:14:07.224089+00 |
| updated_at | 2025-07-21 01:26:14.450155+00 |
| description | A minimal vector math library for 2D and 3D operations in Rust. |
| homepage | https://github.com/Mathieu-Poirier/tiny_vect |
| repository | https://github.com/Mathieu-Poirier/tiny_vect |
| max_upload_size | |
| id | 1761576 |
| size | 34,594 |
A minimal vector math library for 2D and 3D operations in Rust.
Vect2) with comprehensive mathematical operationsVect3) with cross product and 3D-specific operationsAdd this to your Cargo.toml:
[dependencies]
tiny_vect = "0.1.0"
use tiny_vect::{Vect2, Vect3};
fn main() {
// 2D vectors
let a = Vect2::new(3.0, 4.0);
let b = Vect2::new(1.0, 2.0);
println!("Vector a: {}", a);
println!("Length of a: {}", a.length());
println!("a + b: {}", a + b);
println!("Dot product: {}", a.dot(&b));
// 3D vectors
let u = Vect3::new(1.0, 0.0, 0.0);
let v = Vect3::new(0.0, 1.0, 0.0);
println!("Cross product: {}", u.cross(&v));
println!("Distance: {}", u.distance(&v));
}
Vect2)+, -, *, /, +=, -=, *=, /=length(), normalize(), dot(), cross()distance(), angle(), rotate(), lerp()is_zero(), is_normalized(), is_parallel()Vect3)let a = Vect2::new(1.0, 2.0);
let b = Vect2::new(3.0, 4.0);
let sum = a + b; // Vect2 { x: 4.0, y: 6.0 }
let diff = a - b; // Vect2 { x: -2.0, y: -2.0 }
let scaled = a * 2.0; // Vect2 { x: 2.0, y: 4.0 }
let v = Vect2::new(3.0, 4.0);
let length = v.length(); // 5.0
let normalized = v.normalize(); // Vect2 { x: 0.6, y: 0.8 }
let a = Vect2::new(1.0, 0.0);
let b = Vect2::new(0.0, 1.0);
let angle = a.angle_between(&b); // π/2 radians
let a = Vect3::new(1.0, 0.0, 0.0);
let b = Vect3::new(0.0, 1.0, 0.0);
let cross = a.cross(&b); // Vect3 { x: 0.0, y: 0.0, z: 1.0 }
Licensed under: