3ed5bd61bdf0 — Leonard Ritter a month ago
* bidimat test
1 files changed, 77 insertions(+), 0 deletions(-)

A => testing/bidimat.sc
A => testing/bidimat.sc +77 -0
@@ 0,0 1,77 @@ 
+
+
+using import struct
+using import glm
+using import glsl
+
+import ..tukan.use
+using import tukan.rotation
+
+struct mat4bidi plain
+    right : mat4
+    left : mat4
+
+    @@ memo
+    inline __* (cls T)
+        static-if (cls == T)
+            fn (self other)
+                this-type
+                    self.right * other.right
+                    other.left * self.left
+
+    inline... scale
+    case (s : f32,)
+        this-function (vec3 s)
+    case (s : vec3,)
+        is := (/ s)
+        this-type
+            mat4  s.x 0 0 0
+                \ 0 s.y 0 0
+                \ 0 0 s.z 0
+                \ 0 0 0 1
+            mat4  is.x 0 0 0
+                \ 0 is.y 0 0
+                \ 0 0 is.z 0
+                \ 0 0 0 1
+
+    inline... offset
+    case (o : vec3,)
+        io := -o
+        this-type
+            mat4  1 0 0 0
+                \ 0 1 0 0
+                \ 0 0 1 0
+                \ o.x o.y o.z 1
+            mat4  1 0 0 0
+                \ 0 1 0 0
+                \ 0 0 1 0
+                \ io.x io.y io.z 1
+
+    inline... affine
+    case (m : mat3,)
+        im := (transpose m)
+        this-type
+            mat4 m
+            mat4 im
+
+    fn complement (self)
+        self.right * self.left
+
+    fn __repr (self)
+        .. "<mat4bidi "
+            repr self.right
+            " "
+            repr self.left
+            ">"
+
+m :=
+    mat4bidi.offset (vec3 1 2 3)
+
+print
+    mat4bidi.affine (mat3 5)
+
+print
+    m.right * (vec4 0 0 0 1)
+
+
+;
  No newline at end of file