simple-vectors
A simple, dimension-generic vector mathematics library for Rust.
Features
- Dimension and type generic: Works with vectors of any compile-time dimension and scalar type
- Trait integration: Implements
VectorSpace,DotProduct, andInnerSpacefrom thevector-spaceecosystem - Optional parsing: Parsing support via the
parsablefeature
Installation
Add this to your Cargo.toml:
[]
= "0.2"
Quick Start
use Vector;
use InnerSpace;
// Create vectors
let v = new;
let w = new;
// Basic arithmetic
let sum = v + w;
let scaled = v * 2.0;
// Vector operations (require `InnerSpace` trait)
let magnitude = v.magnitude;
let normalized = v.normalize;
Examples
2D Physics Simulation
use Vector;
use InnerSpace;
Generic Dimension Mathematics
use Vector;
use InnerSpace;
let v = new;
let w = new;
let angle = angle_between;
Integration with vector-space Ecosystem
This crate implements standard vector space traits, making it compatible with other libraries:
use Vector;
use ;
let point_a = new;
let point_b = new;
// Calculate distance between points
let dist = distance; // 5.0
// Or manually
let diff = point_b - point_a;
let manual_dist = diff.magnitude; // Also 5.0