You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
MicroMDAEPiano/interpolation.h

80 lines
2.2 KiB

/*
* interpolation.h
*
* interpolation - An interpolation library for Arduino.
* Author: Jose Gama 2015
*
* This library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser
* General Public License as published by the Free Software
* Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* This library is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY; without even the
* implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser
* General Public License along with this library; if not,
* write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/*
* From: https://github.com/tuxcell/interpolationArduino
* replaced all doubles by float (wirtz@parasitstudio.de)
*/
#ifndef interpolation_h
#define interpolation_h
#if defined(ARDUINO) && ARDUINO >= 100
#include <Arduino.h>
#else
#include <WProgram.h>
#endif
class interpolation
{
public:
// constructor
interpolation( void );
interpolation( float x[], float y[], int lenXY);
interpolation( float x[], float y[], int lenXY, float valInterp);
void valueI( float valInterp );
void valuelenXY( int lenXY );
void valueX( float x[]);
void valueY( float y[]);
void valueXM( float XM[]);
void valueZ( float Z[]);
float LinearInterpolate();
float CosineInterpolate();
float CubicInterpolate();
float LagrangeInterpolate();
float QuadraticInterpolate();
float AkimaInterpolate();
private:
float* _x;
float* _y;
float* _XM;
float* _Z;
int _lenXY;
float _valInterp;
float LinearInterp( float x[], float y[], int n, float p );
float CosineInterp( float x[], float y[], int n, float p );
float CubicInterp( float x[], float y[], int n, float p );
float LagrangeInterp( float x[], float y[], int n, float p );
float QuadraticInterp( float x[], float y[], int n, float p );
float AkimaInterp( float x[], float y[], float XM[], float Z[], int n, float p );
};
#endif