Components Interactions Examples Tutorials API FAQ
Options
Menu

Module Math

Index

Functions

clamp

  • clamp(x: number, min: number, max: number): number
  • Clamps x to the range [min, max].

    Parameters

    • x: number

      The value to be clamped.

    • min: number

      The minimum value.

    • max: number

      The maximum value.

    Returns number

    A clamped value in the range [min, max].

degreesToRadians

  • degreesToRadians(degree: number): number

distanceSquared

  • Returns the square of the distance between two points

    Parameters

    Returns number

    dist(p1, p2)^2

inRange

  • inRange(x: number, a: number, b: number): boolean
  • Checks if x is between a and b.

    Parameters

    • x: number

      The value to test if in range

    • a: number

      The beginning of the (inclusive) range

    • b: number

      The ending of the (inclusive) range

    Returns boolean

    Whether x is in [a, b]

isNaN

  • isNaN(n: any): boolean
  • Returns true only if x is NaN

    Parameters

    • n: any

    Returns boolean

isValidNumber

  • isValidNumber(n: any): boolean
  • Returns true if the argument is a number, which is not NaN Numbers represented as strings do not pass this function

    Parameters

    • n: any

    Returns boolean

max

  • max<C>(array: C[], defaultValue: C): C
  • max<T, C>(array: T[], accessor: function, defaultValue: C): C
  • Applies the accessor, if provided, to each element of array and returns the maximum value. If no maximum value can be computed, returns defaultValue.

    Type parameters

    • C

    Parameters

    • array: C[]
    • defaultValue: C

    Returns C

  • Type parameters

    • T

    • C

    Parameters

    • array: T[]
    • accessor: function
        • (t?: T, i?: number): C
        • Parameters

          • Optional t: T
          • Optional i: number

          Returns C

    • defaultValue: C

    Returns C

min

  • min<C>(array: C[], defaultValue: C): C
  • min<T, C>(array: T[], accessor: function, defaultValue: C): C
  • Applies the accessor, if provided, to each element of array and returns the minimum value. If no minimum value can be computed, returns defaultValue.

    Type parameters

    • C

    Parameters

    • array: C[]
    • defaultValue: C

    Returns C

  • Type parameters

    • T

    • C

    Parameters

    • array: T[]
    • accessor: function
        • (t?: T, i?: number): C
        • Parameters

          • Optional t: T
          • Optional i: number

          Returns C

    • defaultValue: C

    Returns C

range

  • range(start: number, stop: number, step?: number): number[]
  • Generates an array of consecutive, strictly increasing numbers in the range [start, stop) separeted by step

    Parameters

    • start: number
    • stop: number
    • Optional step: number

    Returns number[]

Generated using TypeDoc