Page tree
Skip to end of metadata
Go to start of metadata

 



Introduced in

Version:VBS3 20.2.0, VBS4 20.1.0

Description

Description:

Performs interpolation across an array of values.

Defaults to linear interpolation, with additional cosine and cubic options.

Syntax

Syntax:

[valuesArray, targetValue, optType] call fn_vbs_arrayInterpolate

Parameters:
  • valuesArray: Array of Number - An array of numeric values.
  • targetValue: Number - Interpolation target value.
  • optType: String - Interpolation type. Can be:
    • "linear" - Linear interpolation (default).
    • "cosine" - Cosine interpolation.
    • "cubic" - Cubic interpolation.
Return Value:Number - Interpolation result value.

Warning

When using functions in VBS versions older than 3.4, certain limitations and requirements should be kept in mind — the main ones being that capitalization of the function name is crucial, and that #include "\vbs2\headers\function_library.hpp" has to be included in every script that utilizes it.

Examples

Examples:
[[[0,10],[1,20],[2,30]], 1.5, "linear"] call fn_vbs_arrayInterpolate
[[[0,10],[1,20],[2,30]], 1.5, "cubic"] call fn_vbs_arrayInterpolate
[[[0,10],[1,20],[2,30]], 1.5, "cosine"] call fn_vbs_arrayInterpolate
[[[0,10],[1,20],[2,30]], 1.5] call fn_vbs_arrayInterpolate

Additional Information

See also:
Multiplayer:
Problems: