use-vector 0.0.5

Small vector primitives and operations for RustUse
Documentation
  • Coverage
  • 100%
    62 out of 62 items documented9 out of 35 items with examples
  • Size
  • Source code size: 25.59 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 758.45 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • RustUse/use-math
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • CloudBranch

use-vector

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.