Zephyr API 3.6.99
Loading...
Searching...
No Matches
interpolation.h File Reference

Provide linear interpolation functions. More...

#include <stdint.h>
#include <math.h>

Go to the source code of this file.

Functions

static int32_t linear_interpolate (const int32_t *x_axis, const int32_t *y_axis, uint8_t len, int32_t x)
 Perform a linear interpolation across an arbitrary curve.
 

Detailed Description

Provide linear interpolation functions.

Function Documentation

◆ linear_interpolate()

static int32_t linear_interpolate ( const int32_t * x_axis,
const int32_t * y_axis,
uint8_t len,
int32_t x )
inlinestatic

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_axisAscending list of X co-ordinates for y_axis data points
y_axisY co-ordinates for each X data point
lenLength of the x_axis and y_axis arrays
xX 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_tLinear interpolation between the two nearest y_axis values.