Skip to main content

Class: LerpVectorLookupTable

A linearly interpolated N-dimensional lookup table of vectors.

Constructors

constructor

new LerpVectorLookupTable(dimensionCount, vectorLength): LerpVectorLookupTable

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.
vectorLengthnumberThe length of the interpolated vectors (i.e. the number of components in each vector) in the new table. Values less than 0 will be clamped to 0.

Returns

LerpVectorLookupTable

Defined in

src/sdk/utils/datastructures/LerpVectorLookupTable.ts:57

new LerpVectorLookupTable(breakpoints): LerpVectorLookupTable

Creates a lookup table initialized with an array of breakpoints.

Parameters

NameTypeDescription
breakpointsreadonly readonly [Readonly<Omit<Float64Array, "set" | "sort" | "copyWithin">>, number][]An array of breakpoints with which to initialize the new table. Each breakpoint should be expressed as an array, where the first element represents the breakpoint vector, 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. Additionally, the table's vector length will be set to the length of the shortest breakpoint vector.

Returns

LerpVectorLookupTable

Defined in

src/sdk/utils/datastructures/LerpVectorLookupTable.ts:68

Accessors

dimensionCount

get dimensionCount(): number

The number of dimensions in this table.

Returns

number

Defined in

src/sdk/utils/datastructures/LerpVectorLookupTable.ts:36


vectorLength

get vectorLength(): number

The length of the vectors in this table.

Returns

number

Defined in

src/sdk/utils/datastructures/LerpVectorLookupTable.ts:43

Methods

get

get(out, ...key): Float64Array

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

Parameters

NameTypeDescription
outFloat64ArrayThe vector to which to write the result.
...keynumber[]The lookup key, as an ordered N-tuple of numbers.

Returns

Float64Array

The vector corresponding to the specified key.

Throws

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

Defined in

src/sdk/utils/datastructures/LerpVectorLookupTable.ts:159


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 [Readonly<Omit<Float64Array, "set" | "sort" | "copyWithin">>, 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, the breakpoint has fewer dimensions than this table, or the the length of the breakpoint vector is less than this table's vector length property.

Defined in

src/sdk/utils/datastructures/LerpVectorLookupTable.ts:106