# Vector Space Traits
[](https://crates.io/crates/vector-space)
[](https://docs.rs/vector-space)
[](https://crates.io/crates/vector-space)
[](https://crates.io/crates/vector-space)
A collection of traits for generic vector math in Rust. Provides `VectorSpace`, `DotProduct`, `InnerSpace` (with normalize, project, reject, reflect, angle, etc.), and free functions like `distance` and `interpolate`.
Designed for custom vector types (2D, 3D, Geometric Algebra, etc.). Implement once, get dozens of methods for free. Works with `no_std`.
## Features
- **Efficiency**: Inline defaults, no allocations
- **Useful trait methods for inner space**: `magnitude()`, `normalize()`, `project()`, `reject()`, `reflect()`, `angle()`, etc.
- **Flexible for multivectors**: Provides `OuterProduct` and `DotProduct` traits
- **Free functions**: `distance()`, `distance2()`, `interpolate()`
- **`no_std`**: Full support (`libm` for floats)
- **Heterogeneous operations**: `Vector.dot(Rotor)` → `Rotor` (GA-friendly)
## Geometric Algebra Example
```rust
use vector_space::{VectorSpace, InnerSpace, DotProduct};
// Assume your GA types: Vector, Bivector, Rotor
impl VectorSpace for Vector<f32> { type Scalar = f32; }
impl InnerSpace for Vector<f32> {
fn scalar(&self, other: &Self) -> f32 { /* dot */ }
}
impl DotProduct<Bivector<f32>> for Vector<f32> {
type Output = Vector<f32>; // Geometric product grade filter
fn dot(self, biv: Bivector<f32>) -> Vector<f32> { /* impl */ }
}
```