summaryrefslogtreecommitdiff
path: root/frontend/transpiler/MathHelper.h
diff options
context:
space:
mode:
authorMatthew Kosarek <mattkae@protonmail.com>2021-04-10 21:54:43 -0400
committerMatthew Kosarek <mattkae@protonmail.com>2021-04-10 21:54:43 -0400
commit88a08ee48cbbae086ddbfeaff0679bfe4fe6ce47 (patch)
treeb62ec45eeb42b76ea1dae72d3cd8cea614c0194f /frontend/transpiler/MathHelper.h
parent756b9fdefc1a28ac46aa4b76676c7ffb57c9e11a (diff)
Added a transpiler that will make it so that we no longer need any JavaScript of Jquery in our App
Diffstat (limited to 'frontend/transpiler/MathHelper.h')
-rw-r--r--frontend/transpiler/MathHelper.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/frontend/transpiler/MathHelper.h b/frontend/transpiler/MathHelper.h
new file mode 100644
index 0000000..b9c9cb6
--- /dev/null
+++ b/frontend/transpiler/MathHelper.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#define PI 3.14159265358979323846f
+
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#define MAX(a,b) (((a)>(b))?(a):(b))
+#define CLAMP(x, upper, lower) (MIN(upper, MAX(x, lower)))
+#define DTOR (PI / 180.0f)
+#define SWAP(x, y, T) do { T SWAP = x; x = y; y = SWAP; } while (0)
+
+namespace MathHelper {
+ inline float radiansToDegrees(float radians) {
+ return radians * 180.f / PI;
+ }
+
+ inline float degreesToRadians(float degrees) {
+ return degrees * PI / 180.f;
+ }
+
+ inline int nearestPowerOfTwo(int n) {
+ int v = n;
+
+ v--;
+ v |= v >> 1;
+ v |= v >> 2;
+ v |= v >> 4;
+ v |= v >> 8;
+ v |= v >> 16;
+ v++; // next power of 2
+
+ return v;
+ }
+}