#matrix #game #math #vector-math #vector #simd-vector #graphics

nightly no-std definitive

The definitive and final vector & matrix library for Rust

5 releases

0.1.0 Nov 12, 2019
0.0.0-alpha.3 Oct 27, 2019
0.0.0-alpha.1 Oct 25, 2019

#1383 in Game dev

ISC license

23KB
516 lines

Definitive

The definitive vector and matrix library for Rust

use definitive::Vector;

let a = Vector::new([2, 3, 1]);
let b = Vector::new([8, 0, 0]);

let c = a + b * (b * 2);

SIMD

Definitive provides the default feature simd which enables and disables hand written SIMD implementations of certain Vector and Matrix variants. Hand optimized variants are documented under their own traits

#![no_std]

This crate supports #![no_std] environments, and support can be enabled by disabling the std feature

Current issues

The biggest issue currently is supporting arbritrary matrices, as type signature such as the following are not allowed. As far as I can tell, we might get this someday, but const generics are still in their infancy.

struct Matrix<T, const N: usize, const L: [usize; {N}]>([T; { L.iter().product() }]);

Another issue I'm facing is with specialization. I want to allow vec * scalar operations, but I cannot for the life of me figure out a way to do that without adding an unnecessary Copy bound on the vec's T. This is in most cases non issue, and does not cause any inefficiencies as the members of the vec are not actually copied anywhere. In future this bound might get removed, as I learn how to actually use the type system D:

Progress

  • Vector

    • Clone
    • Copy
    • Debug
    • Display
    • Eq
      • PartialEq
    • Add
      • AddAssign
    • Sub
      • SubAssign
    • Mul
      • MulAssign
    • Div
      • DivAssign
    • Rem
      • RemAssign
    • Neg
    • BitAnd
      • BitAndAssign
    • BitOr
      • BitOrAssign
    • BitXor
      • BitXorAssign
    • Shl
      • ShlAssign
    • Shr
      • ShrAssign
    • Not
    • Hash
  • Matrix (blocked on https://github.com/rust-lang/rust/issues/44580)

No runtime deps

Features