Expand description
§use-vector
Small 2D, 3D, and 4D vector primitives for RustUse.
Explicit dot products, cross products, normalization, distances, and interpolation without geometry-specific or matrix-specific abstractions.
§Install
[dependencies]
use-vector = "0.0.5"§What belongs here
use-vector owns plain f64 vector primitives and reusable vector operations.
The current surface includes Vector2, Vector3, Vector4, dot products,
Vector3::cross, norms, normalization, scaling, distances, and linear interpolation.
Scalar division follows normal f64 semantics. Dividing by zero yields infinities or
NaN instead of panicking.
§Neighboring crates
| Crate | Responsibility |
|---|---|
use-vector | Vector primitives and vector operations |
use-matrix | Matrix primitives |
use-linear | Higher-level linear algebra algorithms and matrix-oriented workflows |
use-geometry | Points, shapes, angles, geometric relationships, and spatial algorithms |
use-physics | Physical formulas that use vectors |
use-vector intentionally does not add geometry-specific types, matrices, unit-aware
vectors, or domain-specific physics helpers.
§Examples
§Vector magnitude
use use_vector::Vector2;
let a = Vector2::new(3.0, 4.0);
assert_eq!(a.magnitude(), 5.0);§Dot and cross products
use use_vector::{Vector2, Vector3};
let a = Vector2::new(1.0, 2.0);
let b = Vector2::new(3.0, 4.0);
assert_eq!(a.dot(b), 11.0);
let x = Vector3::new(1.0, 0.0, 0.0);
let y = Vector3::new(0.0, 1.0, 0.0);
assert_eq!(x.cross(y), Vector3::new(0.0, 0.0, 1.0));§Normalization
use use_vector::Vector2;
let unit = Vector2::new(3.0, 4.0)
.normalize()
.expect("non-zero finite vector should normalize");
assert!((unit.x - 0.6).abs() < 1.0e-12);
assert!((unit.y - 0.8).abs() < 1.0e-12);§Distance
use use_vector::Vector3;
let start = Vector3::ZERO;
let end = Vector3::new(2.0, 3.0, 6.0);
assert_eq!(start.distance(end), 7.0);§Status
use-vector is a concrete pre-1.0 crate in the RustUse math workspace. The API stays
small, explicit, and dependency-free so adjacent crates can build on a stable vector core.
Small vector primitives and operations for RustUse.
Modules§
- vector2
- Two-dimensional vector primitives and operations.
- vector3
- Three-dimensional vector primitives and operations.
- vector4
- Four-dimensional vector primitives and operations.