#graphics #matrix-vector #vector #matrix #gamedev #linear-algebra

ezcgmath

Easy linear algebra Math library for use with computer graphics

4 releases

0.0.4 Sep 16, 2020
0.0.3 Sep 16, 2020
0.0.2 Sep 11, 2020
0.0.1 Sep 11, 2020

#61 in #matrix-vector

MIT license

51KB
971 lines

ezcgmath

build crates.io docs.rs

An extremely simplified linear algebra API, for use with computer graphics.

Math should be fun, and easy. This crate aims to simplify the usage of math in computer graphics applications for both the novice, and the expert. This is achieved by providing a super-straightforward API with good documentation, and zero abstraction on the main types.

Implementation Details

The Scalar type is fixed to f32. This was chosen due to its straightforward compatibility with graphics APIs. It is up to the user to create their own abstractions if any limits are hit due to this.

The coordinate system is fixed to being left handed, with Y as up. If you wish to convert to a different coordinate system you may achieve this by creating a reflection matrix and applying it at the appropriate point.

Transformations in this API are applied in a row-major manor. As a reminder, this means that transformations are applied in the order they are specified. For example, if you wanted to scale, then rotate, and then translate a position vector, you would write these transformations in "reading order":

use ezcgmath::prelude::*;

let position_vector = Vector3::new(5.0, 0.0, 0.0);
let scale_matrix = Matrix4x4::from_nonuniform_scale(&Vector3::new(2.0, 1.0, 1.0));
let rotation_matrix = Quaternion::from_axis_angle(&Vector3::new(0.0, 1.0, 0.0), &Degrees(90.0));
let translation_matrix = Matrix4x4::from_translation(&Vector3::new(0.0, 0.0, 10.0));
let transformed_vector = position_vector * scale_matrix * rotation_matrix * translation_matrix;

Disclaimer

ezcgmath is still very much a work in progress. If there are holes you'd like filling, please feel free to open an issue on GitHub so we can start a conversation on it. If you'd like to contribute, that's great! Please read CONTRIBUTING.md for some guidelines on the process.

Dependencies

~190KB