Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace MathUtils

Index

Functions

clamp

  • clamp(value: number, min: number, max: number): number
  • Ensures that input value fits in a given range.

    Parameters

    • value: number

      The value to be clamped.

    • min: number

      Minimum value.

    • max: number

      Maximum value.

    Returns number

    Clamped value.

easeInOutCubic

  • easeInOutCubic(startValue: number, endValue: number, time: number): number
  • Smoothly interpolates between two values using cubic formula

    Parameters

    • startValue: number

      -

    • endValue: number

      -

    • time: number

      -

    Returns number

    Result of the interpolation within the range of [startValue, endValue]

isClamped

  • isClamped(value: number, lowerBound: number | undefined, upperBound: number | undefined): boolean
  • Checks if the value of a given number is inside an upper or lower bound. The bounds may be undefined, in which case their value is ignored.

    Parameters

    • value: number

      Value to check.

    • lowerBound: number | undefined

      The lower bound to check the value against.

    • upperBound: number | undefined

      The upper bound to check the value against.

    Returns boolean

    true if value is inside the bounds or if the bounds are undefined, false otherwise.

map

  • map(val: number, inMin: number, inMax: number, outMin: number, outMax: number): number
  • Maps a number from one range to another.

    Parameters

    • val: number

      The incoming value to be converted.

    • inMin: number

      Lower bound of the value's current range.

    • inMax: number

      Upper bound of the value's current range.

    • outMin: number

      Lower bound of the value's target range.

    • outMax: number

      Upper bound of the value's target range.

    Returns number

max2

  • max2(a: number | undefined, b: number | undefined): number | undefined
  • Returns the larger of the two given numbers. Both numbers may be undefined, in which case the result is undefined. If only one of the numbers is undefined, the other number is returned.

    Parameters

    • a: number | undefined

      First number.

    • b: number | undefined

      Second number.

    Returns number | undefined

min2

  • min2(a: number | undefined, b: number | undefined): number | undefined
  • Returns the smaller of the two given numbers. Both numbers may be undefined, in which case the result is undefined. If only one of the numbers is undefined, the other number is returned.

    Parameters

    • a: number | undefined

      First number.

    • b: number | undefined

      Second number.

    Returns number | undefined

smoothStep

  • smoothStep(edge0: number, edge1: number, x: number): number

smootherStep

  • smootherStep(edge0: number, edge1: number, x: number): number

Generated using TypeDoc