summaryrefslogtreecommitdiff
path: root/sourcemod/scripting/include/gamechaos/vectors.inc
diff options
context:
space:
mode:
authornavewindre <nw@moneybot.cc>2023-12-04 18:06:10 +0100
committernavewindre <nw@moneybot.cc>2023-12-04 18:06:10 +0100
commitaef0d1c1268ab7d4bc18996c9c6b4da16a40aadc (patch)
tree43e766b51704f4ab8b383583bdc1871eeeb9c698 /sourcemod/scripting/include/gamechaos/vectors.inc
parent38f1140c11724da05a23a10385061200b907cf6e (diff)
bbbbbbbbwaaaaaaaaaaa
Diffstat (limited to 'sourcemod/scripting/include/gamechaos/vectors.inc')
-rw-r--r--sourcemod/scripting/include/gamechaos/vectors.inc66
1 files changed, 66 insertions, 0 deletions
diff --git a/sourcemod/scripting/include/gamechaos/vectors.inc b/sourcemod/scripting/include/gamechaos/vectors.inc
new file mode 100644
index 0000000..79d5e8f
--- /dev/null
+++ b/sourcemod/scripting/include/gamechaos/vectors.inc
@@ -0,0 +1,66 @@
+
+#if defined _gamechaos_stocks_vectors_included
+ #endinput
+#endif
+#define _gamechaos_stocks_vectors_included
+
+#define GC_VECTORS_VERSION 0x01_00_01
+#define GC_VECTORS_VERSION_STRING "1.0.1"
+
+/**
+ * Calculates the horizontal (x, y) length of a vector.
+ *
+ * @param vec Vector.
+ * @return Vector length (magnitude).
+ */
+stock float GCGetVectorLength2D(const float vec[3])
+{
+ float tempVec[3];
+ tempVec = vec;
+ tempVec[2] = 0.0;
+
+ return GetVectorLength(tempVec);
+}
+
+/**
+ * Calculates the horizontal (x, y) distance between 2 vectors.
+ *
+ * @param x Vector 1.
+ * @param y Vector 2.
+ * @param tolerance How close the floats have to be to return true.
+ * @return True on success, false otherwise.
+ */
+stock float GCGetVectorDistance2D(const float x[3], const float y[3])
+{
+ float x2[3];
+ float y2[3];
+
+ x2 = x;
+ y2 = y;
+
+ x2[2] = 0.0;
+ y2[2] = 0.0;
+
+ return GetVectorDistance(x2, y2);
+}
+
+/**
+ * Checks if 2 vectors are exactly equal.
+ *
+ * @param a Vector 1.
+ * @param b Vector 2.
+ * @return True on success, false otherwise.
+ */
+stock bool GCVectorsEqual(const float a[3], const float b[3])
+{
+ bool result = true;
+ for (int i = 0; i < 3; i++)
+ {
+ if (a[i] != b[i])
+ {
+ result = false;
+ break;
+ }
+ }
+ return result;
+} \ No newline at end of file