Options
All
• Public
• Public/Protected
• All

# Namespace Math2

## Type aliases

### WeightedAverageWithExclusionInput

WeightedAverageWithExclusionInput: []

### WeightedAverageWithExclusionInputWithOptions

WeightedAverageWithExclusionInputWithOptions: []

## Variables

### Const NUMBERS_COMMA_DECIMAL

NUMBERS_COMMA_DECIMAL: boolean = (0.1).toLocaleString().includes(",")

### Const clamp1

clamp1: (...args: A) => R = clamp.bind(null, 0, 1)

Clamps the given number in the range 0-1

#### Type declaration

• (...args: A): R

### Const clamp255

clamp255: (...args: A) => R = clamp.bind(null, 0, 255)

Clamps the given number in the range 0-255

#### Type declaration

• (...args: A): R

## Functions

### average

• average(...ns: number[]): number

### clamp

• clamp(min: number, max: number, value: number): number
• Clamps the given number in the given range

### lerp

• lerp(from: number, to: number, t: number): number
• Return a number between `from` and `to`, using the decimal `t`

Example: `lerp(1, 2, .5): 1.5`

### mod

• mod(n1: number, n2: number): number

### parseLocalizedFloat

• parseLocalizedFloat(str: string): number

### roundNumber

• roundNumber(num: number, places: number): number
• Returns a number rounded to a certain number of decimal places.

Example: `roundNumber(1.24999999, 2): 1.25`

### roundNumberToMultiple

• roundNumberToMultiple(num: number, multiple: number): number
• Returns a number rounded to a multiple

Example: `roundNumberToMultiple(97, 10): 100`

### sum

• sum(...ns: number[]): number

### unlerp

• unlerp(from: number, to: number, lerped: number): number
• Given a number between `from` and `to`, returns a decimal how far it is, `t`.

### weightedAverage

• weightedAverage(...ns: Array<[]>): number
• Takes an any number of `[weight, number]` tuples, and returns the "weighted average".

#### Parameters

• ##### Rest...ns: Array<[]>

Any number of `[weight, number]` tuples.

For example: `weightedAverage([1, 0], [3, 1])` returns `0.75`.

• One part `0`, three parts `1`. That adds up to four parts, which means each part is worth `0.25`.
• Three parts `1` means `0.25 * 3`, one part `0` means `0 * 1`.
• `0.75 + 0` is `0.75`.

### weightedAverageWithExclusion

• Takes an any number of `[weight, number]` tuples, and returns the "weighted average".

#### Parameters

• ##### Rest...ns: WeightedAverageWithExclusionInput[]

Any number of `[weight, number]` tuples.

For example: `weightedAverage([1, 0], [3, 1])` returns `0.75`.

• One part `0`, three parts `1`. That adds up to four parts, which means each part is worth `0.25`.
• Three parts `1` means `0.25 * 3`, one part `0` means `0 * 1`.
• `0.75 + 0` is `0.75`.

#### Returns number

Generated using TypeDoc