Options

# Module Math

## 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].

### distanceSquared

• Returns the square of the distance between two points

#### 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

### 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

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

#### Parameters

• ##### accessor: function
• (t?: T, i?: number): 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.

#### Parameters

• ##### accessor: function
• (t?: T, i?: number): 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

#### Returns number[]

Generated using TypeDoc