Skip to main content

Class: LerpLookupTable

A linearly interpolated N-dimensional lookup table.

Constructors

constructor

new LerpLookupTable(dimensionCount): LerpLookupTable

Creates a lookup table of a specified dimension.

Parameters

NameTypeDescription
dimensionCountnumberThe number of dimensions in the new table. Values less than 0 will be clamped to 0.

Returns

LerpLookupTable

Defined in

src/sdk/utils/datastructures/LerpLookupTable.ts:39

new LerpLookupTable(breakpoints): LerpLookupTable

Creates a lookup table initialized with an array of breakpoints.

Parameters

NameTypeDescription
breakpointsreadonly readonly number[][]An array of breakpoints with which to initialize the new table. Each breakpoint should be expressed as a number array, where the first element represents the breakpoint value, and the next N elements represent the breakpoint key in each dimension. If not all breakpoint arrays have the same length, the dimension of the table will be set equal to L - 1, where L is the length of the shortest array. For arrays with length greater than L, all keys after index L - 1 will be ignored. If the table ends up with zero dimensions, it will be initialized to an empty table.

Returns

LerpLookupTable

Defined in

src/sdk/utils/datastructures/LerpLookupTable.ts:49

Accessors

dimensionCount

get dimensionCount(): number

The number of dimensions in this table.

Returns

number

Defined in

src/sdk/utils/datastructures/LerpLookupTable.ts:29

Methods

get

get(...key): number

Looks up a value in this table using a specified key. The returned value will be linearly interpolated from surrounding breakpoints if the key is not an exact match for any of the table's breakpoints.

Parameters

NameTypeDescription
...keynumber[]The lookup key, as an ordered N-tuple of numbers.

Returns

number

The value corresponding to the specified key.

Throws

Error if this table has zero dimensions, the key has fewer dimensions than this table, or a value could not be retrieved.

Defined in

src/sdk/utils/datastructures/LerpLookupTable.ts:125


insertBreakpoint

insertBreakpoint(breakpoint): this

Inserts a breakpoint into this table. If the breakpoint has more dimensions than this table, only the first N keys of the breakpoint will be used, where N is the dimension count of this table.

Parameters

NameTypeDescription
breakpointreadonly number[]A breakpoint, as a number array with the value at index 0 followed by the keys for each dimension.

Returns

this

This table, after the breakpoint has been inserted.

Throws

Error if this table has zero dimensions, or the breakpoint has fewer dimensions than this table.

Defined in

src/sdk/utils/datastructures/LerpLookupTable.ts:77