semf
semf::LinearInterpolator< MAX_DIMENSIONS, T_IN, T_TARGET, T_STORAGE > Class Template Reference

Class for calculating the linear interpolation. It interpolates till 3-dimensional data. More...

#include <linearinterpolator.h>

Collaboration diagram for semf::LinearInterpolator< MAX_DIMENSIONS, T_IN, T_TARGET, T_STORAGE >:
Collaboration graph

Public Member Functions

 LinearInterpolator (bool limitToBoundaryValues=true)
 
virtual ~LinearInterpolator ()=default
 
bool init (const T_IN dimension1Data[], uint16_t dimension1DataSize, const T_TARGET targetData[], uint16_t targetDataSize)
 Initializes the class members with 1 dimensional data points. More...
 
bool init (const T_IN dimension1Data[], uint16_t dimension1DataSize, const T_IN dimension2Data[], uint16_t dimension2DataSize, const T_TARGET targetData[], uint16_t targetDataSize)
 Initializes the class members with 2 dimensional data points. More...
 
bool init (const T_IN dimension1Data[], uint16_t dimension1DataSize, const T_IN dimension2Data[], uint16_t dimension2DataSize, const T_IN dimension3Data[], uint16_t dimension3DataSize, const T_TARGET targetData[], uint16_t targetDataSize)
 Initializes the class members with 2 dimensional data points. More...
 
bool setTargetDataInputDimension (const T_TARGET targetData[], uint16_t targetDataSize)
 It updates/changes the m_targetDataSource array. More...
 
bool interpolate (T_TARGET &y, T_IN x1=0, T_IN x2=0, T_IN x3=0)
 Calculates the interpolation of a given data point. More...
 

Detailed Description

template<uint8_t MAX_DIMENSIONS, typename T_IN, typename T_TARGET = T_IN, typename T_STORAGE = T_TARGET>
class semf::LinearInterpolator< MAX_DIMENSIONS, T_IN, T_TARGET, T_STORAGE >

Class for calculating the linear interpolation. It interpolates till 3-dimensional data.

Note
The notation used in this class as follows: value as 'x' and the dimension's number is suffix, i.e. x1 1st dimensional value, x2 2nd dimensional value. so a data point in 3d space (x1, x2, ,x3). The corresponding value (target) of a given point is notated as y .
Template Parameters
MAX_DIMENTIONSMaximum dimensions for interpolation (1, 2, or 3).
T_INData type of inputs.
T_TARGETData type of outputs.
T_STORAGEData type of intermediate results.

Definition at line 31 of file linearinterpolator.h.

Constructor & Destructor Documentation

◆ LinearInterpolator()

template<uint8_t MAX_DIMENSIONS, typename T_IN , typename T_TARGET , typename T_STORAGE >
semf::LinearInterpolator< MAX_DIMENSIONS, T_IN, T_TARGET, T_STORAGE >::LinearInterpolator ( bool  limitToBoundaryValues = true)
explicit

Constructor.

Parameters
limitToBoundaryValuesFlag that allows accepting input data beyond the boundaries, without throwing an error.
Note
  • true If a given data point is beyond the boundaries, then it will be replaced by the boundary point.
  • false If a given data point is beyond the boundaries, then m_retValue is false.

Definition at line 181 of file linearinterpolator.h.

◆ ~LinearInterpolator()

template<uint8_t MAX_DIMENSIONS, typename T_IN , typename T_TARGET = T_IN, typename T_STORAGE = T_TARGET>
virtual semf::LinearInterpolator< MAX_DIMENSIONS, T_IN, T_TARGET, T_STORAGE >::~LinearInterpolator ( )
virtualdefault

Member Function Documentation

◆ init() [1/3]

template<uint8_t MAX_DIMENSIONS, typename T_IN , typename T_TARGET , typename T_STORAGE >
bool semf::LinearInterpolator< MAX_DIMENSIONS, T_IN, T_TARGET, T_STORAGE >::init ( const T_IN  dimension1Data[],
uint16_t  dimension1DataSize,
const T_IN  dimension2Data[],
uint16_t  dimension2DataSize,
const T_IN  dimension3Data[],
uint16_t  dimension3DataSize,
const T_TARGET  targetData[],
uint16_t  targetDataSize 
)

Initializes the class members with 2 dimensional data points.

Parameters
dimension1DataPointer to the elements of the first dimension.
dimension1DataSizeNumber of elements of the first dimension.
dimension2DataPointer to the elements of the second dimension.
dimension2DataSizeNumber of elements of the second dimension.
dimension3DataPointer to the elements of the third dimension.
dimension3DataSizeNumber of elements of the third dimension.
targetDataPointer to the targetDataput dimension data.
targetDataSizeNumber of elements of the targetDataput data.
Returns
false if the number of output elements doesn't match the number of input elements, otherwise returns true.

Definition at line 229 of file linearinterpolator.h.

◆ init() [2/3]

template<uint8_t MAX_DIMENSIONS, typename T_IN , typename T_TARGET , typename T_STORAGE >
bool semf::LinearInterpolator< MAX_DIMENSIONS, T_IN, T_TARGET, T_STORAGE >::init ( const T_IN  dimension1Data[],
uint16_t  dimension1DataSize,
const T_IN  dimension2Data[],
uint16_t  dimension2DataSize,
const T_TARGET  targetData[],
uint16_t  targetDataSize 
)

Initializes the class members with 2 dimensional data points.

Parameters
dimension1DataPointer to the elements of the first dimension.
dimension1DataSizeNumber of elements of the first dimension.
dimension2DataPointer to the elements of the second dimension.
dimension2DataSizeNumber of elements of the second dimension.
targetDataPointer to the targetDataput dimension data.
targetDataSizeNumber of elements of the targetDataput data.
Returns
false if the number of output elements doesn't match the number of input elements, otherwise returns true.

Definition at line 208 of file linearinterpolator.h.

◆ init() [3/3]

template<uint8_t MAX_DIMENSIONS, typename T_IN , typename T_TARGET , typename T_STORAGE >
bool semf::LinearInterpolator< MAX_DIMENSIONS, T_IN, T_TARGET, T_STORAGE >::init ( const T_IN  dimension1Data[],
uint16_t  dimension1DataSize,
const T_TARGET  targetData[],
uint16_t  targetDataSize 
)

Initializes the class members with 1 dimensional data points.

Parameters
dimension1DataPointer to the elements of the first dimension.
targetDataPointer to the targetDataput dimension data.
dimension1DataSizeNumber of elements of the first dimension.
targetDataSizeNumber of elements of the targetDataput data.
Returns
false if the number of output elements doesn't match the number of input elements, otherwise returns true.

Definition at line 189 of file linearinterpolator.h.

◆ interpolate()

template<uint8_t MAX_DIMENSIONS, typename T_IN , typename T_TARGET , typename T_STORAGE >
bool semf::LinearInterpolator< MAX_DIMENSIONS, T_IN, T_TARGET, T_STORAGE >::interpolate ( T_TARGET &  y,
T_IN  x1 = 0,
T_IN  x2 = 0,
T_IN  x3 = 0 
)

Calculates the interpolation of a given data point.

Parameters
yReference to the result (interpolated value).
x1Input data value for the first dimension.
x2Input data value for the second dimension.
x3Input data value for the third dimension.
Returns
Success or failure of the interpolation. If the given data points are targetDataSource of given dimension boundaries.
  • true on correct implementation,
  • false if something goes wrong (e.g. the data point is beyond the boundary and m_limitToBoundaryValues is false).

Definition at line 269 of file linearinterpolator.h.

◆ setTargetDataInputDimension()

template<uint8_t MAX_DIMENSIONS, typename T_IN , typename T_TARGET , typename T_STORAGE >
bool semf::LinearInterpolator< MAX_DIMENSIONS, T_IN, T_TARGET, T_STORAGE >::setTargetDataInputDimension ( const T_TARGET  targetData[],
uint16_t  targetDataSize 
)

It updates/changes the m_targetDataSource array.

Note
On correct given parameters the m_targetDataSource array will be changed, otherwise m_targetDataSource will not be changed.
Parameters
targetDataPointer to the targetDataput dimension data.
targetDataSizeNumber of elements of the targetDataput data.
Returns
false if the number of output elements doesn't match the number of input elements, otherwise returns true.

Definition at line 254 of file linearinterpolator.h.