File utils/mathutil.lua

Functions

mathutil.clamp (value, min, max) Clamps one value to the given minimum/maximum values.
mathutil.next_lower_prime (number) Gets the next lower prime from the given number.
mathutil.round (value, decimal_places) Rounds to the nearest number with the given decimal places.


Functions

mathutil.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.

Return value:

The value clamped to the given range.
mathutil.next_lower_prime (number)
Gets the next lower prime from the given number.

Parameters

  • number: The number.

Return value:

The next lower prime.
mathutil.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.

Return value:

The rounded value.

Valid XHTML 1.0!