aboutsummaryrefslogtreecommitdiff
path: root/src/core/matrix4x4.rs
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2021-02-02 16:07:16 +0100
committerJulian T <julian@jtle.dk>2021-02-02 16:07:38 +0100
commitd79d5d18c8281cce1e782892e5f85680906481dd (patch)
tree3429b142fb76c4999afcc62033b7c4fe9f2ff980 /src/core/matrix4x4.rs
parentdf6a266e5823a7fc4cca3060ec86d35f2125cd0d (diff)
Add matrix and transform implementation
Diffstat (limited to 'src/core/matrix4x4.rs')
-rw-r--r--src/core/matrix4x4.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/core/matrix4x4.rs b/src/core/matrix4x4.rs
new file mode 100644
index 0000000..521d7ab
--- /dev/null
+++ b/src/core/matrix4x4.rs
@@ -0,0 +1,35 @@
+use crate::{Number, Float};
+
+pub struct Matrix4x4<T: Number> {
+ pub m: [[T; 4]; 4],
+}
+
+pub type Matrix4x4f = Matrix4x4<Float>;
+
+impl<T: Number> Matrix4x4<T> {
+ pub fn new(v00: T, v01: T, v02: T, v03: T,
+ v10: T, v11: T, v12: T, v13: T,
+ v20: T, v21: T, v22: T, v23: T,
+ v30: T, v31: T, v32: T, v33: T) -> Self {
+ Self {
+ m: [
+ [v00, v01, v02, v03],
+ [v10, v11, v12, v13],
+ [v20, v21, v22, v23],
+ [v30, v31, v32, v33],
+ ],
+ }
+ }
+}
+
+impl Matrix4x4f {
+ pub fn new_ident(v: Float) -> Self {
+ let z = 0.0;
+ Self::new(
+ v, z, z, z,
+ z, v, z, z,
+ z, z, v, z,
+ z, z, z, v,
+ )
+ }
+}