Finds the closest lower and higher key value, calculates the output column's value using linear interpolation and returns the result. If an exact match of the value is found, then no interpolation is done. If the value is outside the range of keys, then an extrapolation is done.
double InterpolateDic(string dictionaryName; double value; string outputColumnName)
dictionaryName |
The name of the dictionary to interpolate in. |
value |
The value to find the closest lower and higher key value for. |
outputColumnName |
The name of the column to calculate the value for using interpolation. |
Example
InterpolateDic("MovementAtTime", 12.3; "Distance")
Returns the interpolated value of the column "Distance" in the dictionary "MovementAtTime" at the interpolation key value 12.3 (i.e. at the time 12.3 s).
Remarks
This method requires that the keys and referred column of the dictionary are numerical or can be converted to double using "NumberFormatInfo.InvariantInfo".