Options
All
• Public
• Public/Protected
• All

# Class Num

Num class provides various helper functions for basic numeric operations

• Num

## Methods

### Static average

• Sum a group of numeric arrays

#### Parameters

• ##### pts: GroupLike | number[][]

an array of numeric arrays

#### Returns Pt

a array of sums

### Static boundValue

• boundValue(val: number, min: number, max: number): number
• Different from Num.clamp in that the value out-of-bound will be "looped back" to the other end.

example

`boundValue(361, 0, 360)` will return 1

#### Parameters

• ##### val: number

value to bound

min value

max value

### Static clamp

• clamp(val: number, min: number, max: number): number
• Clamp values between min and max

#### Parameters

• ##### val: number

value to clamp

min value

max value

### Static cycle

• cycle(t: number): number
• Given a value between 0 to 1, returns a value that cycles between 0 -> 1 -> 0 using sine method.

#### Parameters

• ##### t: number

a value between 0 to 1

#### Returns number

a value between 0 to 1

### Static equals

• equals(a: number, b: number, threshold?: number): boolean
• Check if two numbers are equal or almost equal within a threshold

#### Parameters

number a

number b

• ##### Default value threshold: number = 0.00001

a threshold within which the two numbers are considered equal

### Static lerp

• lerp(a: number, b: number, t: number): number
• Linear interpolation

#### Parameters

• ##### a: number

start value

end value

• ##### t: number

usually a value between 0 to 1

### Static mapToRange

• mapToRange(n: number, currA: any, currB: any, targetA: any, targetB: any): number
• Map a value from one range to another

#### Parameters

• ##### n: number

a value in the first range

#### Returns number

a remapped value in the second range

### Static normalizeValue

• normalizeValue(n: number, a: number, b: number): number
• Normalize a value within a range

#### Parameters

• ##### n: number

the value to normalize

• ##### a: number

range value 1

• ##### b: number

range value 1

### Static randomRange

• randomRange(a: number, b?: number): number
• Get a random number within a range

#### Parameters

• ##### a: number

range value 1

• ##### Default value b: number = 0

range value 2

### Static sum

• Sum a group of numeric arrays

#### Parameters

• ##### pts: GroupLike | number[][]

an array of numeric arrays

#### Returns Pt

a array of sums

### Static within

• within(p: number, a: number, b: number): boolean
• Check if a value is within

#### Returns boolean

Generated using TypeDoc