![]() |
Speeduino
|
Functions for interpolating values from 3D tables. More...
Go to the source code of this file.
Classes | |
struct | xy_values |
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... | |
Functions | |
static bool | operator== (const xy_values &lhs, const xy_values &rhs) |
Equality operator for xy_values. | |
static void | invalidate_cache (table3DGetValueCache *pCache) |
Invalidate the cache by resetting the last lookup values. | |
template<uint16_t xFactor, uint16_t yFactor> | |
table3d_value_t | get3DTableValue (struct table3DGetValueCache *pValueCache, const table3d_dim_t axisSize, const table3d_value_t *pValues, const table3d_axis_t *pXAxis, const table3d_axis_t *pYAxis, const xy_values &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 table3d_dim_t | axisSize, | ||
const table3d_value_t * | pValues, | ||
const table3d_axis_t * | pXAxis, | ||
const table3d_axis_t * | pYAxis, | ||
const xy_values & | 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. |
axisSize | The size of the axis. |
pValues | Pointer to the table values. |
pXAxis | Pointer to the X axis array. |
pYAxis | Pointer to 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.