Module mathutil
Various mathematical functions.
Functions
-
cantor_pairing (a, b)
-
Uses the Cantor Pairing function on the two given values and returns
a unique integer for the given numbers.
Parameters:
- a
The first value.
- b
The second value.
Returns:
A unique value for the two given values.
-
clamp (value, min, max)
-
Clamps one value to the given minimum/maximum values. Defaults to
0 to 1 if min/max are omitted.
Parameters:
- value
The value to clamp.
- min
Optional. The minimum value, defaults to 0.
- max
Optional. The masximum value, defaults to 1.
Returns:
The value clamped to the given range.
-
distance (a, b)
-
Gets the distance between the two given points or objects.
Parameters:
- a
The first object. Either a position or an ObjectRef.
- b
The second object. Either a position or an ObjectRef.
Returns:
The distance between the two given points or objects.
-
in_range (value, min, max)
-
Tests if the given value is within the given range.
Parameters:
- value
The value to test.
- min
The minimum value. It can also be a table with either two values,
the first being the minimum and the second being the maximum, or
with two named values, min and max.
- max
The maximum value. Not used if min is a table.
-
next_lower_prime (number)
-
Gets the next lower prime from the given number.
Parameters:
Returns:
The next lower prime.
-
round (value, decimal_places)
-
Rounds to the nearest number with the given decimal places.
Parameters:
- value
The value to round.
- decimal_places
Optional. The number of decimal places to round to,
defaults to 0.
Returns:
The rounded value.
Fields
-
SIGNED_8BIT_MAX
-
The maximum value a signed 8bit integer can have.
-
SIGNED_8BIT_MIN
-
The minimum value a signed 8bit integer can have.
-
SIGNED_16BIT_MAX
-
The maximum value a signed 16bit integer can have.
-
SIGNED_16BIT_MIN
-
The minimum value a signed 16bit integer can have.
-
SIGNED_32BIT_MAX
-
The maximum value a signed 32bit integer can have.
-
SIGNED_32BIT_MIN
-
The minimum value a signed 32bit integer can have.
-
UNSIGNED_8BIT_MAX
-
The maximum value an unsigned 8bit integer can have.
-
UNSIGNED_8BIT_MIN
-
The minimum value an unsigned 8bit integer can have.
-
UNSIGNED_16BIT_MAX
-
The maximum value an unsigned 16bit integer can have.
-
UNSIGNED_16BIT_MIN
-
The minimum value an unsigned 16bit integer can have.
-
UNSIGNED_32BIT_MAX
-
The maximum value an unsigned 32bit integer can have.
-
UNSIGNED_32BIT_MIN
-
The minimum value an unsigned 32bit integer can have.