Created
June 15, 2016 09:42
-
-
Save feliwir/212a6704636b6464b0a6dc4a7ef7f6d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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