Linear interpolation utilities for mathematical operations
More...
Linear interpolation utilities for mathematical operations
◆ linear_interpolate()
#include <zephyr/math/interpolation.h>
Perform a linear interpolation across an arbitrary curve.
- Note
- Result rounding occurs away from 0, e.g: 1.5 -> 2, -5.5 -> -6
- Parameters
-
| x_axis | Ascending list of X co-ordinates for y_axis data points |
| y_axis | Y co-ordinates for each X data point |
| len | Length of the x_axis and y_axis arrays |
| x | X co-ordinate to lookup |
- Return values
-
| y_axis[0] | if x < x_axis[0] |
| y_axis[len | - 1] if x > x_axis[len - 1] |
| int32_t | Linear interpolation between the two nearest y_axis values. |