From 904ef85f5468eb840f64115f9a2c20ec2aca9119 Mon Sep 17 00:00:00 2001 From: SpookyDervish Date: Fri, 23 Jan 2026 16:47:56 +1100 Subject: [PATCH] package wip --- math/SUMMARY.md | 23 +++++++++++++++++++++++ math/docs/clamp.md | 16 ++++++++++++++++ math/docs/max.md | 15 +++++++++++++++ math/docs/min.md | 15 +++++++++++++++ math/docs/modulus.md | 15 +++++++++++++++ math/docs/pow.md | 14 ++++++++++++++ math/docs/random/random.md | 22 ++++++++++++++++++++++ math/docs/random/random_double.md | 22 ++++++++++++++++++++++ math/docs/random/random_set_seed.md | 20 ++++++++++++++++++++ math/docs/sqrt.md | 14 ++++++++++++++ math/docs/trig/cos.md | 14 ++++++++++++++ math/docs/trig/deg_to_rad.md | 14 ++++++++++++++ math/docs/trig/rad_to_deg.md | 14 ++++++++++++++ math/docs/trig/sin.md | 14 ++++++++++++++ math/docs/trig/tan.md | 14 ++++++++++++++ math/mineral.ini | 7 +++++++ stdlib/mineral.ini | 8 ++++---- test.grnd | 4 ++-- 18 files changed, 259 insertions(+), 6 deletions(-) create mode 100644 math/SUMMARY.md create mode 100644 math/docs/clamp.md create mode 100644 math/docs/max.md create mode 100644 math/docs/min.md create mode 100644 math/docs/modulus.md create mode 100644 math/docs/pow.md create mode 100644 math/docs/random/random.md create mode 100644 math/docs/random/random_double.md create mode 100644 math/docs/random/random_set_seed.md create mode 100644 math/docs/sqrt.md create mode 100644 math/docs/trig/cos.md create mode 100644 math/docs/trig/deg_to_rad.md create mode 100644 math/docs/trig/rad_to_deg.md create mode 100644 math/docs/trig/sin.md create mode 100644 math/docs/trig/tan.md create mode 100644 math/mineral.ini diff --git a/math/SUMMARY.md b/math/SUMMARY.md new file mode 100644 index 0000000..51717aa --- /dev/null +++ b/math/SUMMARY.md @@ -0,0 +1,23 @@ +# math +Library that contains math utilities. + +## General +- [math_Modulus](docs/modulus.md) +- [math_Min](docs/min.md) +- [math_Max](docs/max.md) +- [math_Clamp](docs/clamp.md) +- [math_Sqrt](docs/sqrt.md) +- [math_Pow](docs/pow.md) + +## Trig Functions +- [math_Sin](docs/trig/sin.md) +- [math_Cos](docs/trig/cos.md) +- [math_Tan](docs/trig/tan.md) +- [math_RadiansToDegrees](docs/trig/rad_to_deg.md) +- [math_DegreesToRadians](docs/trig/deg_to_rad.md) + +## Random +- [math_Random](docs/random/random.md) +- [math_RandomDouble](docs/random/random_double.md) +- [math_RandomSetSeed](docs/random/random_set_seed.md) + diff --git a/math/docs/clamp.md b/math/docs/clamp.md new file mode 100644 index 0000000..d37ccda --- /dev/null +++ b/math/docs/clamp.md @@ -0,0 +1,16 @@ +# math_Clamp +Clamps a number between a minimum and maximum value. + +## Arguments +- number (double): The number to be clamped +- min (double): Minimum value +- max (double): Maximum value + +## Returns +result (double): The number after being clamped + +## Example +```python +call !math_Clamp 1.5 0.0 1.0 &result +println $result # 1.0 +``` \ No newline at end of file diff --git a/math/docs/max.md b/math/docs/max.md new file mode 100644 index 0000000..f6e8609 --- /dev/null +++ b/math/docs/max.md @@ -0,0 +1,15 @@ +# math_Max +Choose the largest number out of the two arguments. + +## Arguments +- number1 (double): First number +- number2 (double): Second number + +## Returns +result (double): The largest number out of the two provided + +## Example +```python +call !math_Max 1.2 0.7 &result +println $result # 1.2 +``` \ No newline at end of file diff --git a/math/docs/min.md b/math/docs/min.md new file mode 100644 index 0000000..8596a57 --- /dev/null +++ b/math/docs/min.md @@ -0,0 +1,15 @@ +# math_Min +Choose the smallest number out of the two arguments. + +## Arguments +- number1 (double): First number +- number2 (double): Second number + +## Returns +result (double): The smallest number out of the two provided + +## Example +```python +call !math_Min 0.5 1.5 &result +println $result # 0.5 +``` \ No newline at end of file diff --git a/math/docs/modulus.md b/math/docs/modulus.md new file mode 100644 index 0000000..c16ae68 --- /dev/null +++ b/math/docs/modulus.md @@ -0,0 +1,15 @@ +# math_Modulus +Gets the remainder of dividing the two numbers. + +## Arguments +- number1 (double): First number +- number2 (double): Second number + +## Returns +remainder (double): The remainder. + +## Example +```python +call !math_Modulus 4 3 &remainder +println $remainder # 1 +``` \ No newline at end of file diff --git a/math/docs/pow.md b/math/docs/pow.md new file mode 100644 index 0000000..d98f54c --- /dev/null +++ b/math/docs/pow.md @@ -0,0 +1,14 @@ +# math_Pow +Gets the + +## Arguments +- number (double): The number to get the square root of + +## Returns +result (double): The square root of the number + +## Example +```python +call !math_Sqrt 16 &result +println $result # 4 +``` \ No newline at end of file diff --git a/math/docs/random/random.md b/math/docs/random/random.md new file mode 100644 index 0000000..ede5592 --- /dev/null +++ b/math/docs/random/random.md @@ -0,0 +1,22 @@ +# math_Random +Generate a random integer in the range provided. +**IMPORTANT:** math_Random is **NOT** cryptographically secure! Use the `cryptography` library instead! +If you want to generate a random double, use `math_RandomDouble`. + +## Arguments +- min (int): Smallest possible number +- max (int): Largest possible number + +## Returns +randomNumber (int): A random number in the range provided + +## Example +```python +call !math_Random 1 6 &dice +println $dice # 3 +call !math_Random 1 6 &dice +println $dice # 2 +call !math_Random 1 6 &dice +println $dice # 6 +... +``` \ No newline at end of file diff --git a/math/docs/random/random_double.md b/math/docs/random/random_double.md new file mode 100644 index 0000000..4f262ad --- /dev/null +++ b/math/docs/random/random_double.md @@ -0,0 +1,22 @@ +# math_RandomDouble +Generate a random double in the range provided. +**IMPORTANT:** math_RandomDouble is **NOT** cryptographically secure! Use the `cryptography` library instead! +If you want to generate a random integer, use `math_Random`. + +## Arguments +- min (double): Smallest possible number +- max (double): Largest possible number + +## Returns +randomNumber (double): A random number in the range provided + +## Example +```python +call !math_RandomDouble 0.0 10.0 &randomNumber +println $randomNumber # 5.24... +call !math_RandomDouble 0.0 10.0 &randomNumber +println $randomNumber # 6.58... +call !math_RandomDouble 0.0 10.0 &randomNumber +println $randomNumber # 9.22... +... +``` \ No newline at end of file diff --git a/math/docs/random/random_set_seed.md b/math/docs/random/random_set_seed.md new file mode 100644 index 0000000..d6ca700 --- /dev/null +++ b/math/docs/random/random_set_seed.md @@ -0,0 +1,20 @@ +# math_RandomSetSeed +Seed the pseudo random number generator. +Seeding the random number generator the same number will always yield the same random number. + +## Arguments +- seed (int): Seed + +## Returns +math_RandomSetSeed does not return anything. + +## Example +```python +call !math_RandomSetSeed 123 & +call !math_Random 1 6 &dice +println $dice # some number +call !math_RandomSetSeed 123 & +call !math_Random 1 6 &dice +println $dice # the same number +# (i cant test this cause libraries are broken as am i writing docs lmao) +``` \ No newline at end of file diff --git a/math/docs/sqrt.md b/math/docs/sqrt.md new file mode 100644 index 0000000..6d6c5c1 --- /dev/null +++ b/math/docs/sqrt.md @@ -0,0 +1,14 @@ +# math_Sqrt +Gets the square root of a number. + +## Arguments +- number (double): The number to get the square root of + +## Returns +result (double): The square root of the number + +## Example +```python +call !math_Sqrt 16 &result +println $result # 4 +``` \ No newline at end of file diff --git a/math/docs/trig/cos.md b/math/docs/trig/cos.md new file mode 100644 index 0000000..9288b1f --- /dev/null +++ b/math/docs/trig/cos.md @@ -0,0 +1,14 @@ +# math_Cos +Get the cosine of a certain amount of radians. + +## Arguments +- x (double): Number (in radians) + +## Returns +result (double): The cosine of the number in radians + +## Example +```python +call !math_Cos 3.14159 &result +println $result # -1 +``` \ No newline at end of file diff --git a/math/docs/trig/deg_to_rad.md b/math/docs/trig/deg_to_rad.md new file mode 100644 index 0000000..5a6563e --- /dev/null +++ b/math/docs/trig/deg_to_rad.md @@ -0,0 +1,14 @@ +# math_DegreesToRadians +Convert degrees to radians. + +## Arguments +- x (double): Number of degrees + +## Returns +result (double): x degrees in radians + +## Example +```python +call !math_DegreesToRadians 180.0 &result +println $result # 3.14159 +``` \ No newline at end of file diff --git a/math/docs/trig/rad_to_deg.md b/math/docs/trig/rad_to_deg.md new file mode 100644 index 0000000..d955f23 --- /dev/null +++ b/math/docs/trig/rad_to_deg.md @@ -0,0 +1,14 @@ +# math_RadiansToDegrees +Convert radians to degrees. + +## Arguments +- x (double): Number of radians + +## Returns +result (double): x radians in degrees + +## Example +```python +call !math_RadiansToDegrees 3.14159 &result +println $result # 180.0 +``` \ No newline at end of file diff --git a/math/docs/trig/sin.md b/math/docs/trig/sin.md new file mode 100644 index 0000000..1e70a82 --- /dev/null +++ b/math/docs/trig/sin.md @@ -0,0 +1,14 @@ +# math_Sin +Get the sine of a certain amount of radians. + +## Arguments +- x (double): Number (in radians) + +## Returns +result (double): The sine of the number in radians + +## Example +```python +call !math_Sin 3.14159 &result +println $result # 0 +``` \ No newline at end of file diff --git a/math/docs/trig/tan.md b/math/docs/trig/tan.md new file mode 100644 index 0000000..2baa4af --- /dev/null +++ b/math/docs/trig/tan.md @@ -0,0 +1,14 @@ +# math_Tan +Get the tangent of a certain amount of radians. + +## Arguments +- x (double): Number (in radians) + +## Returns +result (double): The tangent of the number in radians + +## Example +```python +call !math_Tan 3.14159 &result +println $result # 0 +``` \ No newline at end of file diff --git a/math/mineral.ini b/math/mineral.ini new file mode 100644 index 0000000..652b228 --- /dev/null +++ b/math/mineral.ini @@ -0,0 +1,7 @@ +[package] +description = Library that contains math utilities. +version = 1.2.5 +config_version = 1 + +[dependencies] + diff --git a/stdlib/mineral.ini b/stdlib/mineral.ini index 9abce85..2614a09 100644 --- a/stdlib/mineral.ini +++ b/stdlib/mineral.ini @@ -1,10 +1,10 @@ [package] description = Standard library for Ground. -version = 1.2.0 +version = 1.2.5 config_version = 1 [dependencies] -math=1.2.0 -request=1.2.0 -fileio=1.2.0 +math=1.2.5 +request=1.2.5 +fileio=1.2.5 diff --git a/test.grnd b/test.grnd index 38a85ee..7aeefc9 100644 --- a/test.grnd +++ b/test.grnd @@ -1,4 +1,4 @@ extern "math" -call !math_RandomDouble 1.0 10.0 &dice -println $dice \ No newline at end of file +call !math_RandomDouble 1.0 10.0 &var +println $var \ No newline at end of file