diff --git a/fixed_wide_vectors/src/lib.rs b/fixed_wide_vectors/src/lib.rs index 775c4e6..a9c0b41 100644 --- a/fixed_wide_vectors/src/lib.rs +++ b/fixed_wide_vectors/src/lib.rs @@ -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; diff --git a/fixed_wide_vectors/src/matrix.rs b/fixed_wide_vectors/src/matrix.rs new file mode 100644 index 0000000..f95a0ee --- /dev/null +++ b/fixed_wide_vectors/src/matrix.rs @@ -0,0 +1,27 @@ +use crate::{Vector2,Vector3,Vector4}; + +pub struct Matrix2 { + pub x_axis: T, + pub y_axis: T, +} +pub struct Matrix3 { + pub x_axis: T, + pub y_axis: T, + pub z_axis: T, +} +pub struct Matrix4 { + 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 }) );