1 module matmul;
2
3 import std.stdio;
4
5 extern(C) int glm_matmul(int iter);
6
7 int glmMatMul(int iter)
8 {
9 return glm_matmul(iter);
10 }
11
12 int gfxMatMul(int iter)
13 {
14 import gfx.math;
15 const axis = fvec(1, 2, 3);
16 const sc = fvec(0.5, 2, 0.5);
17 const tr = fvec(4, 5, 6);
18 const even = rotation(0.01, axis) * scale(sc) * translation(tr);
19 const odd = rotation(0.01, axis) * scale(1f / sc) * translation(-tr);
20 auto m = FMat4.identity;
21
22 foreach (i; 0 .. iter) {
23 if (i % 2) {
24 m = odd * m;
25 }
26 else {
27 m = even * m;
28 }
29 }
30
31 // writeln("gfx:", m);
32 if (m == FMat4.identity) {
33 writeln("only to make sure computation is not optimized away");
34 }
35
36 return iter;
37 }
38
39
40 int gl3nMatMul(int iter)
41 {
42 import gl3n.linalg;
43 const axis = vec3(1, 2, 3);
44 const sc = vec3(0.5, 2, 0.5);
45 const tr = vec3(4, 5, 6);
46 const r = quat.axis_rotation(0.01, axis.normalized).to_matrix!(4, 4);
47 const even = r * mat4.scaling(sc.x, sc.y, sc.z) * mat4.translation(tr);
48 const odd = r * mat4.scaling(1f/sc.x, 1f/sc.y, 1f/sc.z) * mat4.translation(-tr);
49 auto m = mat4.identity;
50
51 foreach (i; 0 .. iter) {
52 if (i % 2) {
53 m = odd * m;
54 }
55 else {
56 m = even * m;
57 }
58 }
59
60 //writeln("gl3n:", m);
61 if (m == mat4.identity) {
62 writeln("only to make sure computation is not optimized away");
63 }
64 return iter;
65 }
66