![]() |
Speeduino
|
Functions for interpolating values from 3D tables. More...
Go to the source code of this file.
Classes | |
| struct | xy_pair_t |
| A pair of x and y values used for lookups in 3D tables. More... | |
| struct | xy_coord2d |
| 2D coordinate structure for table lookups More... | |
| struct | table3DGetValueCache |
| Cache structure for 3D table value lookups. More... | |
| struct | row_col2d |
| Row and column coordinates in a 2D table. More... | |
Functions | |
| static void | invalidate_cache (table3DGetValueCache *pCache) |
| Invalidate the cache by resetting the last lookup values. | |
| template<uint16_t xFactor, uint16_t yFactor, typename TValues , typename TXAxis , typename TYAxis > | |
| table3d_value_t | get3DTableValue (struct table3DGetValueCache *pValueCache, const TValues &values, const TXAxis &xAxis, const TYAxis &yAxis, const xy_pair_t &lookupValues) |
| Get a value from a 3D table using the specified lookup values. | |
Functions for interpolating values from 3D tables.
| table3d_value_t get3DTableValue | ( | struct table3DGetValueCache * | pValueCache, |
| const TValues & | values, | ||
| const TXAxis & | xAxis, | ||
| const TYAxis & | yAxis, | ||
| const xy_pair_t & | lookupValues | ||
| ) |
Get a value from a 3D table using the specified lookup values.
Conceptually, a 3d table consists of a 2D table (rows & columns) and 2 axes. E.g. 6x6 table (tables are always square):
YMax | V V V V V V
Y | V V V V V V
Y | V V V V V V
Y | V V V V V V
Y | V V V V V V
YMin | V V V V V V
-----+-------------------
| X X X X X X
|Min Max
Our overall task is to accurately interpolate a value from the table, given X and Y axis values. The x/y values will likely be in-between axis values. The function performs a 2D linear interpolation as described in: www.megamanual.com/v22manual/ve_tuner.pdf
| xFactor | The factor used to scale the lookup value to/from the same units as the axis values. |
| yFactor | The factor for the Y axis values. |
| pValueCache | Pointer to the value cache structure. |
| values | The table values. |
| xAxis | The X axis array. |
| yAxis | The Y axis array. |
| lookupValues | The X axis and Y axis values to look up. |
|
inlinestatic |
Invalidate the cache by resetting the last lookup values.