Module mathutil

Various mathematical functions.

Functions

clamp (value, min, max) Clamps one value to the given minimum/maximum values.
distance (a, b) Gets the distance between the two given points or objects.
in_range (value, min, max) Tests if the given value is within the given range.
next_lower_prime (number) Gets the next lower prime from the given number.
round (value, decimal_places) Rounds to the nearest number with the given decimal places.


Functions

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:

  • number The number.

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.
generated by LDoc 1.4.2