Structs and methods for linear algebra.
This crate provides 3 main types of structs that implement basic arithmetic operations like + and -, and also pervide useful methods:
- Structs for handling vectors like Vec2 and Vec3.
- Structs for handling arrays of vectors with different types of memory orginization, like Vec3arr and Vec3box, for fixed length arrays and boxed arrays respectively.
- Structs for handling square matricies like Mat22 and Mat33.
Vectors can be easily initialized and used:
use Vec3;
let a : Vec3 = UP;
let b : Vec3 = Vec3 ;
assert_eq!;
Arrays of vectors can be used to parallelize arithmetic:
use Vec3;
use Vec3arr;
//using a and b from last example:
let ab : Vec3arr = Vec3arr;
let cd : Vec3arr = Vec3arr;
assert_eq!;
Matricies are indexed like x1, y2, z3 ... where x, y, z are the rows and 1, 2, 3 are the columns:
use Vec3;
use Mat33;
//using a and b from first example:
let c : Vec3 = Vec3;
let m1 : Mat33 = augment;
let m2 : Mat33 = Mat33
assert_eq!;