31 if (x < data.front().X)
35 slope = (data[1].Y - y0) / (data[1].X - x0);
37 if (x > data.back().X)
41 slope = (data[data.size() - 2].Y - y0) / (data[data.size() - 2].X - x0);
45 for (
size_t tmp = 0; tmp < data.size() - 1; ++tmp)
49 else if ((data[tmp].X <= x) && (data[tmp + 1].X >= x))
53 slope = (data[tmp + 1].Y - y0) / (data[tmp + 1].X - x0);
58 return y0 + slope * (x - x0);
72 if (el.
GetName() !=
"LinearInterpolation")
75 _(
"Wrong XML element."));
78 std::vector<crn::Point2DDouble> newdata;
82 newdata.back().Deserialize(sel);
105 Cloner::Register<LinearInterpolation>();
xml::Element Serialize(xml::Element &parent) const
StringUTF8 GetName() const
Gets the label of the element.
Element BeginElement()
Gets the first child element.
#define CRN_END_CLASS_CONSTRUCTOR(classname)
Defines a class constructor.
void Deserialize(xml::Element &el)
#define CRN_DATA_FACTORY_REGISTER(elemname, classname)
Registers a class to the data factory.
virtual double operator[](double x) const override
Gets ordinate at x.
A character string class.
Element PushBackElement(const StringUTF8 &name)
Adds an element at the end of the children list.
Element EndElement()
Gets a null node.
Invalid argument error (e.g.: nullptr pointer)
#define CRN_BEGIN_CLASS_CONSTRUCTOR(classname)
Defines a class constructor.