initial matrix type

This commit is contained in:
Quaternions 2024-08-30 13:02:48 -07:00
parent 263f0d35d4
commit 0f0d7f7a9a
2 changed files with 32 additions and 0 deletions

View File

@ -1,9 +1,14 @@
mod macros;
mod vector;
mod matrix;
pub use vector::Vector2;
pub use vector::Vector3;
pub use vector::Vector4;
pub use matrix::Matrix2;
pub use matrix::Matrix3;
pub use matrix::Matrix4;
#[cfg(test)]
mod tests;

View File

@ -0,0 +1,27 @@
use crate::{Vector2,Vector3,Vector4};
pub struct Matrix2<T> {
pub x_axis: T,
pub y_axis: T,
}
pub struct Matrix3<T> {
pub x_axis: T,
pub y_axis: T,
pub z_axis: T,
}
pub struct Matrix4<T> {
pub x_axis: T,
pub y_axis: T,
pub z_axis: T,
pub w_axis: T,
}
crate::impl_matrix!((Matrix2 { x_axis, y_axis }, ((T, T), (T, T)), 2), (Vector2, 2), (Vector2 { x, y }) );
crate::impl_matrix!((Matrix2 { x_axis, y_axis }, ((T, T, T), (T, T, T)), 2), (Vector3, 3), (Vector3 { x, y, z }) );
crate::impl_matrix!((Matrix2 { x_axis, y_axis }, ((T, T, T, T), (T, T, T, T)), 2), (Vector4, 4), (Vector4 { x, y, z, w }) );
crate::impl_matrix!((Matrix3 { x_axis, y_axis, z_axis }, ((T, T), (T, T), (T, T)), 3), (Vector2, 2), (Vector2 { x, y }) );
crate::impl_matrix!((Matrix3 { x_axis, y_axis, z_axis }, ((T, T, T), (T, T, T), (T, T, T)), 3), (Vector3, 3), (Vector3 { x, y, z }) );
crate::impl_matrix!((Matrix3 { x_axis, y_axis, z_axis }, ((T, T, T, T), (T, T, T, T), (T, T, T, T)), 3), (Vector4, 4), (Vector4 { x, y, z, w }) );
crate::impl_matrix!((Matrix4 { x_axis, y_axis, z_axis, w_axis }, ((T, T), (T, T), (T, T), (T, T)), 4), (Vector2, 2), (Vector2 { x, y }) );
crate::impl_matrix!((Matrix4 { x_axis, y_axis, z_axis, w_axis }, ((T, T, T), (T, T, T), (T, T, T), (T, T, T)), 4), (Vector3, 3), (Vector3 { x, y, z }) );
crate::impl_matrix!((Matrix4 { x_axis, y_axis, z_axis, w_axis }, ((T, T, T, T), (T, T, T, T), (T, T, T, T), (T, T, T, T)), 4), (Vector4, 4), (Vector4 { x, y, z, w }) );