From 2e836469146271e0e8496dd398d4e4da1f3f8b09 Mon Sep 17 00:00:00 2001 From: AURUMVORXX Date: Mon, 11 Nov 2024 10:49:25 +0300 Subject: [PATCH] fix: Fixed missing math functions --- g2o/__init__.py | 4 +++ g2o/functions/math.py | 63 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 g2o/functions/math.py diff --git a/g2o/__init__.py b/g2o/__init__.py index 7962cd4..6fe1d6b 100644 --- a/g2o/__init__.py +++ b/g2o/__init__.py @@ -19,6 +19,10 @@ from g2o.functions.chat import sendMessageToPlayer from g2o.functions.chat import sendPlayerMessageToAll from g2o.functions.chat import sendPlayerMessageToPlayer +from g2o.functions.math import getDistance2d +from g2o.functions.math import getDistance3d +from g2o.functions.math import getVectorAngle + from g2o.functions.game import getHostname from g2o.functions.game import getMaxSlots from g2o.functions.game import getPlayersCount diff --git a/g2o/functions/math.py b/g2o/functions/math.py new file mode 100644 index 0000000..dc1e9d3 --- /dev/null +++ b/g2o/functions/math.py @@ -0,0 +1,63 @@ +import sqg2o + +def getDistance2d(x1 : float, y1: float, x2 : float, y2 : float) -> float: + """ + This function will get the 2d distance between two points. + Original: [getDistance2d](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/shared-functions/math/getDistance2d/) + + ## Declaration + ```python + def getDistance2d(x1 : float, y1: float, x2 : float, y2 : float) -> float + ``` + + ## Parameters + * `float` **x1**: the position on X axis of the first point. + * `float` **y1**: the position on Y axis of the first point. + * `float` **x2**: the position on X axis of the second point. + * `float` **y2**: the position on Y axis of the second point. + ## Returns + `float`: Returns the calculated 2d distance between two points as floating point number. + """ + return sqg2o.getDistance2d(x1, y1, x2, y2) + +def getDistance3d(x1 : float, y1: float, z1 : float, x2 : float, y2 : float, z2 : float) -> float: + """ + This function will get the 3d distance between two points. + Original: [getDistance3d](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/shared-functions/math/getDistance3d/) + + ## Declaration + ```python + def getDistance3d(x1 : float, y1: float, z1 : float, x2 : float, y2 : float, z2 : float) -> float + ``` + + ## Parameters + * `float` **x1**: the position on X axis of the first point. + * `float` **y1**: the position on Y axis of the first point. + * `float` **z1**: the position on Z axis of the first point. + * `float` **x2**: the position on X axis of the second point. + * `float` **y2**: the position on Y axis of the second point. + * `float` **z2**: the position on Z axis of the second point. + ## Returns + `float`: Returns the calculated 3d distance between two points as floating point number. + """ + return sqg2o.getDistance3d(x1, y1, z1, x2, y2, z2) + +def getVectorAngle(x1 : float, y1: float, x2 : float, y2 : float) -> float: + """ + This function will get angle on Y axis directed towards the second point. + Original: [getVectorAngle](https://gothicmultiplayerteam.gitlab.io/docs/0.3.0/script-reference/shared-functions/math/getVectorAngle/) + + ## Declaration + ```python + def getVectorAngle(x1 : float, y1: float, x2 : float, y2 : float) -> float + ``` + + ## Parameters + * `float` **x1**: the position on X axis of the first point. + * `float` **y1**: the position on Y axis of the first point. + * `float` **x2**: the position on X axis of the second point. + * `float` **y2**: the position on Y axis of the second point. + ## Returns + `float`: Returns the angle on Y axis directed towards the second point. + """ + return sqg2o.getVectorAngle(x1, y1, x2, y2) \ No newline at end of file