Skip to content

Instantly share code, notes, and snippets.

@feliwir
Created June 15, 2016 09:42
Show Gist options
  • Save feliwir/212a6704636b6464b0a6dc4a7ef7f6d1 to your computer and use it in GitHub Desktop.
Save feliwir/212a6704636b6464b0a6dc4a7ef7f6d1 to your computer and use it in GitHub Desktop.
#pragma once
#include <map>
namespace anvil
{
template<class xtype, class ytype>
class Interpolate
{
public:
inline void AddPoint(const xtype x, const ytype y)
{
m_points[x] = y;
}
virtual ytype GetPoint(const xtype x) = 0;
protected:
std::map<xtype,ytype> m_points;
};
template<class xtype,class ytype>
class LinearInterpolate : public Interpolate<xtype,ytype>
{
public:
ytype GetPoint(const xtype x)
{
auto it = m_points.find(x);
if(it!=m_points.end())
return it.second;
ytype lower = m_points.lower_bound(x);
ytype upper = m_points.upper_bound(x);
return 0;
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment