Class: Lookahead
A calculator for lookahead values based on past trends. The calculator accepts a series of input values separated by discrete time intervals, computes a rate of change at each time step, and uses this rate of change to predict what the input value will be at some arbitrary length of time in the future assuming the rate of change remains constant.
Constructors
constructor
• new Lookahead(lookahead
, valueSmoothingTau?
, trendSmoothingTau?
): Lookahead
Constructor.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
lookahead | number | undefined | This calculator's lookahead time. |
valueSmoothingTau | number | 0 | The smoothing time constant to apply to the calculator's input values before rate of change is computed. A value of 0 is equivalent to no smoothing. Defaults to 0 . |
trendSmoothingTau | number | 0 | The smoothing time constant to apply to the calculator's computed trend values. A value of 0 is equivalent to no smoothing. Defaults to 0 . |
Returns
Defined in
src/sdk/math/Lookahead.ts:26
Properties
lookahead
• lookahead: number
This calculator's lookahead time.
Defined in
src/sdk/math/Lookahead.ts:26
Methods
last
▸ last(smoothed?
): null
| number
Gets this calculator's last computed lookahead value. The lookahead value is the predicted value of this calculator's input when projected into the future by an amount equal to the lookahead time assuming the current rate of change of the input remains constant.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
smoothed | boolean | false | Whether to retrieve the lookahead value computed using the last smoothed input value instead of the raw input value as the present (t = 0 ) value. Defaults to false . |
Returns
null
| number
This calculator's last computed lookahead value.
Defined in
src/sdk/math/Lookahead.ts:39
lastTrend
▸ lastTrend(): number
Gets this calculator's last computed trend value. The trend value is the equal to the rate of change of this calculator's input values multiplied by the lookahead time.
Returns
number
This calculator's last computed trend value.
Defined in
src/sdk/math/Lookahead.ts:48
next
▸ next(value
, dt
, smoothed?
): number
Adds a new input value and gets the next lookahead value. The lookahead value is the predicted value of this calculator's input when projected into the future by an amount equal to the lookahead time assuming the current rate of change of the input remains constant.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
value | number | undefined | The new input value. |
dt | number | undefined | The elapsed time since the last input value was added. |
smoothed | boolean | false | Whether to return the lookahead value computed using the smoothed input value instead of the raw input value as the present (t = 0 ) value. Note that this argument does not determine whether smoothing is applied for the purposes of calculating rate of change (smoothing is always applied for this purpose if a positive time constant is defined). Defaults to false . |
Returns
number
The next lookahead value.
Defined in
src/sdk/math/Lookahead.ts:64
nextTrend
▸ nextTrend(value
, dt
): number
Adds a new input value and gets the next trend value. The trend value is the equal to the rate of change of this calculator's input values multiplied by the lookahead time.
Parameters
Name | Type | Description |
---|---|---|
value | number | The new input value. |
dt | number | The elapsed time since the last input value was added. |
Returns
number
The next trend value.
Defined in
src/sdk/math/Lookahead.ts:99
reset
▸ reset(): null
Resets the "history" of this calculator and sets the initial input value to null.
Returns
null
Defined in
src/sdk/math/Lookahead.ts:107
▸ reset<T
>(value
): T
Resets the "history" of this calculator and sets the initial input value.
Type parameters
Name | Type |
---|---|
T | extends null | number |
Parameters
Name | Type | Description |
---|---|---|
value | T | The new initial input value. |
Returns
T
The reset lookahead value, which will be equal to the initial input value.
Defined in
src/sdk/math/Lookahead.ts:113
▸ reset(value?
): null
| number
Resets the "history" of this calculator and optionally sets the initial input value.
Parameters
Name | Type | Description |
---|---|---|
value? | null | number | The new initial input value. Defaults to null. |
Returns
null
| number
The reset lookahead value, which will be equal to the initial input value.
Defined in
src/sdk/math/Lookahead.ts:119