13 releases (3 major breaking)
Uses new Rust 2024
| 18446744073709551615… | Sep 6, 2025 |
|---|---|
| 2.0.1 | Sep 5, 2025 |
| 1.0.2 | Sep 2, 2025 |
| 0.2.0 | Apr 15, 2025 |
| 0.1.4 | Jan 28, 2025 |
#339 in Math
645 downloads per month
2.5MB
904 lines
Mats
Mats is a matrix math library written in Rust, designed to provide lightweight, efficient, and easy-to-use matrix types and algorithms. It includes commonly used matrix algorithm encapsulation in fields such as linear algebra and computer graphics.
Features
uniforms: If this feature is enabled,Matswill implement traitAsUniformValuefor specific types of matrices, allowing them to interact with OpenGL.graphics: If this feature is enabled,Matswill provide tools for computer graphics, such as coordinate transformation matrices.
Example
use mats::Mat2;
fn main() {
let a = Mat2::I();
let b = Mat2::new([[1.0, 2.0], [3.0, 4.0]]);
let c = a + b;
println!("c = {:?}", c);
}
License
Licensed under either of MIT license or Apache License, Version 2.0 at your option.
Release Notes
Release v2.0.1
Fix
- Add attribute
#[inline]to a simple function. - Revise the implementation of trait
Indexfor typeMat. - Supplement the implementation of trait
IndexMutfor typeMat.
Release v2.0.0
Features
A vector is a matrix with only one column. The matrix is column-major
-
Matrix:
- Addition, subtraction, multiplication, division and their assignment of matrices.
- Transposition of matrices.
- Dot product of matrices.
- Cross product of 3D vectors.
- Like GLSL vector member access syntax.
- Vector types alias.
-
GLSL Data Interface(with feature
uniforms):- Implement trait
AsUniformValue(from crateglium) for specific matrix types.
- Implement trait
-
Computer Graphics(with feature
graphics):- If feature
graphicsis enabled, the featureuniformsis also enabled automatically.
- Coorinate transformations:
- 2D/3D: Translation, rotation, scaling.
- Projection: Orthographic, perspective.
- Viewport transformation.
- If feature
Before v2.0.0
This crate was originally born to solidify my Rust programming skills. Later, I tried some OpenGL tools and added matrix algorithms used in OpenGL to it. I think it could be more complete. So, starting from v2.0.0, I plan to refactor it based on my understanding of Rust updates, and make it a great choice for content related to matrix algorithms in Rust!
Futures
I plan to refactor the project in the future to make it easier to use and maintain. In version 2.0.0, I will prioritize basic matrix operations and some basic operations, as well as parts related to computer graphics. More content related to linear algebra, as well as matrix calculations such as robot kinematics, robot inverse kinematics, and neural networks, will be added in the future.
Dependencies
~0–21MB
~265K SLoC