aboutsummaryrefslogtreecommitdiff
path: root/src/Math/Vec2i.c
diff options
context:
space:
mode:
authorMikhail Romanko <me@blankhex.com>2025-02-28 10:08:05 +0300
committerMikhail Romanko <me@blankhex.com>2025-02-28 10:08:05 +0300
commitb0fbfcd69eee59aa2d2428ddd88be158089bf481 (patch)
treeb975c7bb671834bbfe749b3d715678a4ce671b70 /src/Math/Vec2i.c
parent54e1c88f1f9ab89b1c5ca3fda878fd92c1d77191 (diff)
downloadbhlib-b0fbfcd69eee59aa2d2428ddd88be158089bf481.tar.gz
Split Math.c into smaller files
Friend said that Math.c was too big and complicated.
Diffstat (limited to 'src/Math/Vec2i.c')
-rw-r--r--src/Math/Vec2i.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/Math/Vec2i.c b/src/Math/Vec2i.c
new file mode 100644
index 0000000..94601ec
--- /dev/null
+++ b/src/Math/Vec2i.c
@@ -0,0 +1,73 @@
+#include <BH/Math.h>
+
+
+void BH_Vec2iAdd(const int *a,
+ const int *b,
+ int *out)
+{
+ out[0] = a[0] + b[0];
+ out[1] = a[1] + b[1];
+}
+
+
+void BH_Vec2iSub(const int *a,
+ const int *b,
+ int *out)
+{
+ out[0] = a[0] - b[0];
+ out[1] = a[1] - b[1];
+}
+
+
+void BH_Vec2iMul(const int *a,
+ const int *b,
+ int *out)
+{
+ out[0] = a[0] * b[0];
+ out[1] = a[1] * b[1];
+}
+
+
+void BH_Vec2iScale(const int *a,
+ int b,
+ int *out)
+{
+ out[0] = a[0] * b;
+ out[1] = a[1] * b;
+}
+
+
+void BH_Vec2iMulAdd(const int *a,
+ const int *b,
+ const int *c,
+ int *out)
+{
+ out[0] = a[0] * b[0] + c[0];
+ out[1] = a[1] * b[1] + c[1];
+}
+
+
+void BH_Vec2iNegate(const int *in,
+ int *out)
+{
+ out[0] = -in[0];
+ out[1] = -in[1];
+}
+
+
+void BH_Vec2iMin(const int *a,
+ const int *b,
+ int *out)
+{
+ if (a[0] < b[0]) out[0] = a[0]; else out[0] = b[0];
+ if (a[1] < b[1]) out[1] = a[1]; else out[1] = b[1];
+}
+
+
+void BH_Vec2iMax(const int *a,
+ const int *b,
+ int *out)
+{
+ if (a[0] > b[0]) out[0] = a[0]; else out[0] = b[0];
+ if (a[1] > b[1]) out[1] = a[1]; else out[1] = b[1];
+}