![]() |
Speeduino
|
Support functions for 3D table interpolation. More...
Functions | |
Interpolation | |
| TESTABLE_INLINE_STATIC QU1X8_t | compute_bin_position (const uint16_t &value, const table3d_bin_t &bin, const uint16_t &multiplier) |
| Compute the % position of a value within a bin. | |
| TESTABLE_INLINE_STATIC row_col2d | toTopRight (const table3d_bin_t &xBin, const table3d_bin_t &yBin, const table3d_dim_t &axisSize) |
| Get the top right corner of the value coordinates in a 3D table, based on x/y axis coords. | |
| static row_col2d | toBottomLeft (const row_col2d &topRight, const table3d_dim_t &axisSize) |
| Get the bottom left corner of the value coordinates in a 3D table, based on top right corner. | |
| TESTABLE_INLINE_STATIC table3d_value_t | bilinear_interpolation (const table3d_value_t &tl, const table3d_value_t &tr, const table3d_value_t &bl, const table3d_value_t &br, const QU1X8_t &dx, const QU1X8_t &dy) |
| 2d interpolation, given 4 corner values and x/y percentages | |
| table3d_value_t | interpolate_3d_value (const xy_pair_t &lookUpValues, const table3d_dim_t &axisSize, const table3d_value_t *pValues, const table3d_bin_t &xBin, const uint16_t xMultiplier, const table3d_bin_t &yBin, const uint16_t yMultiplier) |
| Interpolate a table value from axis bins & values. | |
Fixed point math | |
| typedef uint16_t | QU1X8_t |
| Unsigned fixed point number type with 1 integer bit & 8 fractional bits. | |
| constexpr QU1X8_t | QU1X8_INTEGER_SHIFT = 8 |
| Integer shift to convert to/from QU1X8_t. | |
| TESTABLE_CONSTEXPR QU1X8_t | QU1X8_ONE = toQU1X8(1U) |
| Precomputed value of 1 in QU1X8_t. | |
| TESTABLE_CONSTEXPR QU1X8_t | QU1X8_HALF = QU1X8_ONE/2U |
| Precomputed value of 0.5 in QU1X8_t. | |
| static constexpr QU1X8_t | toQU1X8 (uint16_t base) |
| Unsigned fixed point number type with 1 integer bit & 8 fractional bits. | |
| static constexpr uint16_t | fromQU1X8 (QU1X8_t base) |
| Unsigned fixed point number type with 1 integer bit & 8 fractional bits. | |
| TESTABLE_INLINE_STATIC QU1X8_t | mulQU1X8 (QU1X8_t a, QU1X8_t b) |
| Multiply two QU1X8_t values. | |
Support functions for 3D table interpolation.
| typedef uint16_t QU1X8_t |
Unsigned fixed point number type with 1 integer bit & 8 fractional bits.
This is specialised for the number range 0..1 - a generic fixed point class would miss some important optimisations. Specifically, we can avoid type promotion during multiplication.
| TESTABLE_INLINE_STATIC table3d_value_t bilinear_interpolation | ( | const table3d_value_t & | tl, |
| const table3d_value_t & | tr, | ||
| const table3d_value_t & | bl, | ||
| const table3d_value_t & | br, | ||
| const QU1X8_t & | dx, | ||
| const QU1X8_t & | dy | ||
| ) |
2d interpolation, given 4 corner values and x/y percentages
tl----------------tr | | | | | | |>>>>>dx>>>>? | | ^ | | dy | | ^ | bl----------------br
| tl | Top left value |
| tr | Top right value |
| bl | Bottom left value |
| br | Bottom right value |
| dx | X distance |
| dy | Y distance |
| TESTABLE_INLINE_STATIC QU1X8_t compute_bin_position | ( | const uint16_t & | value, |
| const table3d_bin_t & | bin, | ||
| const uint16_t & | multiplier | ||
| ) |
Compute the % position of a value within a bin.
| value | The value to check. |
| bin | The axis bin. |
| multiplier | The multiplier for the axis values. |
|
staticconstexpr |
Unsigned fixed point number type with 1 integer bit & 8 fractional bits.
This is specialised for the number range 0..1 - a generic fixed point class would miss some important optimisations. Specifically, we can avoid type promotion during multiplication.
| table3d_value_t interpolate_3d_value | ( | const xy_pair_t & | lookUpValues, |
| const table3d_dim_t & | axisSize, | ||
| const table3d_value_t * | pValues, | ||
| const table3d_bin_t & | xBin, | ||
| const uint16_t | xMultiplier, | ||
| const table3d_bin_t & | yBin, | ||
| const uint16_t | yMultiplier | ||
| ) |
Interpolate a table value from axis bins & values.
| lookUpValues | The x & y axis values we are interpolating |
| axisSize | The length of an axis |
| pValues | The interpolation source values |
| xBin | The x-axis bin containing lookUpValues.x |
| xMultiplier | The x-axis multiplier |
| yBin | The y-axis bin containing lookUpValues.y |
| yMultiplier | The y-axis multiplier |
| TESTABLE_INLINE_STATIC QU1X8_t mulQU1X8 | ( | QU1X8_t | a, |
| QU1X8_t | b | ||
| ) |
Multiply two QU1X8_t values.
|
inlinestatic |
Get the bottom left corner of the value coordinates in a 3D table, based on top right corner.
|
staticconstexpr |
Unsigned fixed point number type with 1 integer bit & 8 fractional bits.
This is specialised for the number range 0..1 - a generic fixed point class would miss some important optimisations. Specifically, we can avoid type promotion during multiplication.
| TESTABLE_INLINE_STATIC row_col2d toTopRight | ( | const table3d_bin_t & | xBin, |
| const table3d_bin_t & | yBin, | ||
| const table3d_dim_t & | axisSize | ||
| ) |
Get the top right corner of the value coordinates in a 3D table, based on x/y axis coords.
| TESTABLE_CONSTEXPR QU1X8_t QU1X8_HALF = QU1X8_ONE/2U |
Precomputed value of 0.5 in QU1X8_t.
|
constexpr |
Integer shift to convert to/from QU1X8_t.
| TESTABLE_CONSTEXPR QU1X8_t QU1X8_ONE = toQU1X8(1U) |
Precomputed value of 1 in QU1X8_t.