summaryrefslogtreecommitdiff
path: root/frontend/_wasm/mathlib.h
diff options
context:
space:
mode:
authorMatthew Kosarek <mattkae@protonmail.com>2021-03-16 22:03:10 -0400
committerMatthew Kosarek <mattkae@protonmail.com>2021-03-16 22:03:10 -0400
commit1a08dd2bd6839f0be4b12dc5317ab0b00ca23ae1 (patch)
treef204817e3dd98358016006d04c39f6ff84c52754 /frontend/_wasm/mathlib.h
parent98d7d6cb702af2708f20e7cf16ee10a9f71b578a (diff)
Proper update loop for a WebAssembly scene running
Diffstat (limited to 'frontend/_wasm/mathlib.h')
-rw-r--r--frontend/_wasm/mathlib.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/frontend/_wasm/mathlib.h b/frontend/_wasm/mathlib.h
index bc84b72..93ddbbd 100644
--- a/frontend/_wasm/mathlib.h
+++ b/frontend/_wasm/mathlib.h
@@ -86,6 +86,13 @@ struct Mat4x4 {
return result;
}
+ Mat4x4 translateByVec2(Vector2 v) {
+ Mat4x4 result = copy();
+ result.m[12] += v.x;
+ result.m[13] += v.y;
+ return result;
+ }
+
Mat4x4 rotate2D(float angle) {
Mat4x4 result = copy();
result.m[0] = cos(angle);
@@ -112,4 +119,12 @@ struct Mat4x4 {
result.m[13] = -(top + bottom) / (top - bottom);
return result;
}
-}; \ No newline at end of file
+
+ void print() {
+ printf("[ ");
+ for (int idx = 0; idx < 16; idx++) {
+ printf("%d, ", idx);
+ }
+ printf(" ]\n");
+ }
+};