52 #ifndef __PCL_LinearInterpolation_h
53 #define __PCL_LinearInterpolation_h
58 #include <pcl/Diagnostics.h>
77 template <
typename T =
double>
107 return this->m_y.Length() > 1;
115 PCL_PRECONDITION( IsValid() )
121 PCL_CHECK( this->m_x.Length() >= this->m_y.Length() )
123 int i1 = this->m_x.Length() - 1;
126 int im = (i0 + i1) >> 1;
127 if ( x < this->m_x[im] )
132 double x0( this->m_x[i0] );
133 double y0( this->m_y[i0] );
134 double dx = double( this->m_x[i1] ) - x0;
136 y0 += (x - x0)*(
double( this->m_y[i1] ) - y0)/dx;
145 if ( x >= this->m_y.Length()-1 )
146 return this->m_y[this->m_y.Length()-1];
148 double y0( this->m_y[i0] );
149 return y0 + (x - i0)*(
double( this->m_y[i0+1] ) - y0);
Generic vector of arbitrary length.
Linear interpolation algorithm.
~LinearInterpolation() override
LinearInterpolation(const LinearInterpolation &)=default
bool IsValid() const override
double operator()(double x) const override
LinearInterpolation()=default
A generic interface to one-dimensional interpolation algorithms.
int TruncInt(T x) noexcept