Spinning Topp Logo BlackTopp Studios
inc
interpolator.h
Go to the documentation of this file.
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _interpolator_h
41 #define _interpolator_h
42 
43 /// @file
44 /// @brief Helper classes to assist in generating data points between two other data points.
45 
46 #include "datatypes.h"
47 #include "exception.h"
48 #include "cubicspline.h"
49 #include "serialization.h"
50 
51 #ifndef SWIG // STD headers are bad for Swig
52  #include <cmath>
53  #include <iterator>
54 
55  #include <iostream>
56  #include <typeinfo>
57 
58  #include "XML/xml.h"
59 #endif
60 
61 namespace Mezzanine
62 {
63  // Forward declaration
64  template <typename InterpolatableType, typename InterpolatorType> class TrackStorage;
65 
66  /// @brief A simple functor for interpolating data points in a simple way.
67  /// @details This interpolator provides certain guarantees.
68  /// - All data points will be valid interpolated values.
69  /// - There are "corners".
70  /// - Interpolation will be constant/O(1) time (and as fast as reasonable).
71  /// - This shape defined by interpolating a set of these will not leave a Convex Hull (or
72  /// Axis Aligned Bounding Box) that could contain the data
73  ///
74  /// @n
75  /// Corners can be thought of as any non-smooth change, and may not be intuitively in some
76  /// interpolatable types.
77  template <typename T>
79  {
80  public:
81  /// @brief The type this will interpolate
82  /// @note All Interpolators need to declare an InterpolatableType
83  typedef T InterpolatableType;
84  /// @brief The storage to use with thison tracks
85  typedef std::vector<InterpolatableType> Storage;
86 
87  /// @brief Get a value at a given location between exactly two others.
88  /// @param Begin The data point at one end of line segment
89  /// @param End The data point at the other end of line segment
90  /// @param Location A value between 0.0 and 1.0 indicate what point on the line segment defined by Begin and End you want.
91  /// @return A Value equal to Begin if 0.0 is passed, equal to End if 1.0 is passed equal to a point exactly in the middle if 0.5 is passed.
92  static T InterpolateMath(T Begin, T End, Real Location)
93  { return ((End-Begin)*Location)+Begin; }
94 
95  /// @brief Handles Interpolation of multiple points.
96  /// @details This will treat each data point as if it were equidistant from its
97  /// neighbors and find the datasegment the desired point resides in. Then it will
98  /// return a data point partway through that data segment. For example if you have
99  /// three Vector2's defining two data segments as follows:
100  /// @n 0,0 - 1,1 - 2,0
101  /// @n @n
102  /// Requesting the following locations would return the following data points:
103  /// @n 0.0 = 0,0
104  /// @n 0.5 = 1,1
105  /// @n 1.0 = 2,0
106  /// @n
107  /// @n 0.25 = 0.5,0.5
108  /// @n 0.75 = 1.5,0.5
109  /// @n @n Any floating point location between 0 and 1 could be requested following
110  /// this pattern.
111  /// @n @n Should the data segments not actually be equal in size that they will each
112  /// still be treated as an equal length when calcuting size. For example if you
113  /// have 2 data segments like the previous example, then .25 will be halfway through
114  /// the first segment and .75 will be halfwy through the second. If you are
115  /// interpolating a series of points through segment like these the larger data
116  /// segment will be traversed faster. For example consider the following Real value
117  /// values as data points:
118  /// @n -5, 0, 100
119  /// Requesting the following locations would return the following data points:
120  /// @n 0.0 = -5
121  /// @n 0.5 = 0
122  /// @n 1.0 = 100
123  /// @n
124  /// @n 0.25 = -2.5
125  /// @n 0.75 = 50
126  /// @n
127  /// @n 0.0 = -5
128  /// @n 0.1 = -4
129  /// @n 0.2 = -3
130  /// @n 0.3 = -2
131  /// @n 0.4 = -1
132  /// @n 0.5 = 0
133  /// @n 0.6 = 20
134  /// @n 0.7 = 40
135  /// @n 0.8 = 60
136  /// @n 0.9 = 80
137  /// @n 1.0 = 100
138  /// @n @n Note how even though the location increase by only 0.1 each step
139  /// the resulting interpolated data point move relative to the length of the
140  /// segment.
141  /// @param Begin An iterator at the beginning of a rande of data point
142  /// @param End An iterator one past the end of the data range to interpolate.
143  /// @param Location A value between 0.0 and 1.0 that represents
144  /// @return A T at a location along the data segments defined by Begin and End.
145  template<typename TIterator>
146  static T GetInterpolatedFromMultiple(TIterator Begin, TIterator End, Real Location)
147  {
148  Whole DataPointCount = std::distance(Begin,End);
149  Whole LineSegmentCount = DataPointCount-1;
150 
151  if(LineSegmentCount<1)
152  { MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_RANGE_EXCEPTION,"Cannot GetPercentageThroughSegment in GenericLinearInterpolator without a data segment. There must be two or more data points."); }
153  if(1==LineSegmentCount)
154  { return InterpolateMath(*(Begin), *(Begin+1), Location); }
155 
156  Whole UsingLineSegment = Location * Real(LineSegmentCount); // Pick a Line Segment
157  if(UsingLineSegment>=LineSegmentCount) // We are past or at the end of the line segments
158  { return *(End-1); }
159 
160  Real LocalPercentage = std::fmod(PreciseReal(Location), PreciseReal(1.0/PreciseReal(LineSegmentCount)))*LineSegmentCount;
161 
162  return InterpolateMath(*(Begin+UsingLineSegment), // The first point of the line segment
163  *(Begin+UsingLineSegment+1),
164  LocalPercentage); // The percentage we are through this line segment
165  }
166 
167  /// @brief This will interpolates data point with @ref GetInterpolatedFromMultiple or
168  /// InterpolateMath as required.
169  /// @details read about @ref GetInterpolatedFromMultiple or @ref InterpolateMath to see
170  /// what kinds of results this can produce.
171  /// @param Begin An iterator at the beginning of a range of data point
172  /// @param End An iterator one past the end of the data range to interpolate.
173  /// @param Location A value between 0.0 and 1.0 that represents
174  /// @return A T at a location along the data segments defined by Begin and End.
175  template<typename TIterator>
176  static T Interpolate(TIterator Begin, TIterator End, Real Location)
177  {
178  if(Begin==End)
179  { MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_RANGE_EXCEPTION,"Requires at least 2 data points for linear interpolation, was provided 0."); }
180  if(Begin+1==End)
181  { MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_RANGE_EXCEPTION,"Requires at least 2 data points for linear interpolation, was provided 1."); }
182 
183  if(Begin+2==End)
184  { return InterpolateMath(*Begin, *(Begin+1), Location); }
185 
186  return GetInterpolatedFromMultiple(Begin, End, Location);
187  }
188 
189  /// @brief Append a node for with enough information to deserialize to the passed node
190  /// @note Very little data is actually serialized, most of it is type information that
191  /// is not easily deserialized.
192  /// @param CurrentRoot A node to act as the parent for the serialized version of this
193  /// one.
194  static void ProtoSerialize(XML::Node& CurrentRoot)
195  {
196  Mezzanine::XML::Node LinearInterpolaterNode = CurrentRoot.AppendChild(GetSerializableName());
197 
198  if(LinearInterpolaterNode)
199  {
200  Mezzanine::XML::Attribute VersionAttr = LinearInterpolaterNode.AppendAttribute("Version");
201  Mezzanine::XML::Attribute TypeAttr = LinearInterpolaterNode.AppendAttribute("InterpolatableType");
202  if( VersionAttr )
203  {
204  if( VersionAttr.SetValue("1") && TypeAttr.SetValue(InterpolatableType::GetSerializableName()) )
205  {
206  return;
207  }else{
208  SerializeError("Create XML Attribute Values", GetSerializableName(),true);
209  }
210  }else{
211  SerializeError("Create XML Attributes", GetSerializableName(),true);
212  }
213  }else{
214  SerializeError("Create XML Serialization Node", GetSerializableName(),true);
215  }
216  }
217 
218  /// @brief This does not create or change the object it deserializes, but it does verify
219  /// type info.
220  /// @param OneNode The node to read serialized data from.
221  static void ProtoDeSerialize(const XML::Node& OneNode)
222  {
223  if ( String(OneNode.Name())==String(GetSerializableName()) )
224  {
225  if(OneNode.GetAttribute("Version").AsInt() == 1)
226  {
227  if(OneNode.GetAttribute("InterpolatableType").AsString() == InterpolatableType::GetSerializableName())
228  {
229  return; // Class currently stores no data.
230  }else{
231  MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_INVALID_EXCEPTION,"Incompatible InterpolatableType Version for " + GetSerializableName() + ": Not " + InterpolatableType::GetSerializableName());
232  }
233  }else{
234  MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + GetSerializableName() + ": Not Version 1.");
235  }
236  }else{
237  MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_INVALID_EXCEPTION,"Attempting to deserialize a " + GetSerializableName() + ", found a " + String(OneNode.Name()) + ".");
238  }
239 
240  }
241 
242  /// @brief get the name of this class for serialization purposes
243  /// @return A String containing "BezierInterpolator"
245  { return String("LinearInterpolator"); }
246  };
247 
248 
249  /// @brief A simple functor for interpolating data points in a simple way.
250  /// @details This interpolator provides different guarantees different from the linear one:
251  /// - Data points, might not be valid interpolated values
252  /// - There are no "Corners".
253  /// - Execution could be as bad as O^N.
254  /// - This shape defined by interpolating a set of these will not leave a Convex Hull (or
255  /// Axis Aligned Bounding Box) that could contain the data.
256  /// - Will be able to provide interpolated values for a small set of data points.
257  /// @n
258  /// There might be corners when connecting 2 different bezier curves if not careful, any
259  /// bezier implementation taking a finite amount of points cannot help this.
260  template <typename T>
262  {
263  public:
264  /// @brief The type this will interpolate
265  /// @note All Interpolators need to declare an InterpolatableType
267  /// @brief The storage to use with thison tracks
268  typedef std::vector<InterpolatableType> Storage;
269 
270  /// @brief Get a value at a given location between two others.
271  /// @details This uses Linear interpolation recursively to produce a single curve
272  /// following Bézier's curve algorithm. For example if interpolating the location 0.5
273  /// on a set of 3 data points A,B,C and therefor 2 data segments AB and BC, you can
274  /// imagine this as getting the point halfway down AB and the point halfway down down
275  /// BC. Then this will get return the halfway between each of those points. This
276  /// produces smooth curves but could perform slowly. For more details see the wikiedia
277  /// pages on Bézier curves:
278  /// http://en.wikipedia.org/wiki/Bézier_curve or
279  /// http://en.wikipedia.org/wiki/B%C3%A9zier_curve
280  /// @param Begin An Iterator to the begining of the range of the instances of the type
281  /// to be Interpolated
282  /// @param End The end (not one past the end) of the range that Begin started.
283  /// @param Location A value between 0.0 and 1.0 indicate what point on the bezier
284  /// spline defined by Begin and End you want.
285  /// @return A Value equal or near to Begin if 0.0 is passed, equal to or near to End if
286  /// 1.0 is passed equal to a point exactly in the middle if 0.5 is passed.
287  /// @warning This is implemented as a recursive function with the only termination
288  /// condition being the end iterator.
289  template<typename TIterator>
290  static T Interpolate(TIterator Begin, TIterator End, Real Location)
291  {
292  if(Begin==End || Begin+1==End)
293  { MEZZ_EXCEPTION(ExceptionBase::PARAMETERS_RANGE_EXCEPTION,"Requires at least 1 data points for bezier interpolation."); }
294 
295  if(Begin+2==End)
296  { return LinearInterpolator<T>::Interpolate(Begin,End,Location); }
297 
298  std::vector<T> SubSection;
299  for(TIterator Iter=Begin; Iter!=End-1; Iter++)
300  { SubSection.push_back(LinearInterpolator<T>::Interpolate(Iter,(Iter+2),Location)); }
301  return Interpolate(SubSection.begin(),SubSection.end(),Location);
302  }
303 
304  /// @brief Append a node for with enough information to deserialize to the passed node
305  /// @note Very little data is actually serialized, most of it is type information that
306  /// is not easily deserialized.
307  /// @param CurrentRoot A node to act as the parent for the serialized version of this
308  /// one.
309  static void ProtoSerialize(XML::Node& CurrentRoot)
310  {
311  Mezzanine::XML::Node BezierInterpolaterNode = CurrentRoot.AppendChild(GetSerializableName());
312 
313  if(BezierInterpolaterNode)
314  {
315  Mezzanine::XML::Attribute VersionAttr = BezierInterpolaterNode.AppendAttribute("Version");
316  Mezzanine::XML::Attribute TypeAttr = BezierInterpolaterNode.AppendAttribute("InterpolatableType");
317  if( VersionAttr )
318  {
319  if( VersionAttr.SetValue("1") && TypeAttr.SetValue(InterpolatableType::GetSerializableName()) )
320  {
321  return;
322  }else{
323  SerializeError("Create XML Attribute Values", GetSerializableName(),true);
324  }
325  }else{
326  SerializeError("Create XML Attributes", GetSerializableName(),true);
327  }
328  }else{
329  SerializeError("Create XML Serialization Node", GetSerializableName(),true);
330  }
331  }
332 
333  /// @brief This does not create or change the object it deserializes, but it does verify
334  /// type info.
335  /// @param OneNode The node to read serialized data from.
336  static void ProtoDeSerialize(const XML::Node& OneNode)
337  {
338  if ( String(OneNode.Name())==String(GetSerializableName()) )
339  {
340  if(OneNode.GetAttribute("Version").AsInt() == 1)
341  {
342  if(OneNode.GetAttribute("InterpolatableType").AsString() == InterpolatableType::GetSerializableName())
343  {
344  return; // Class currently stores no data.
345  }else{
346  MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_INVALID_EXCEPTION,"Incompatible InterpolatableType Version for " + GetSerializableName() + ": Not " + InterpolatableType::GetSerializableName());
347  }
348  }else{
349  MEZZ_EXCEPTION(ExceptionBase::INVALID_VERSION_EXCEPTION,"Incompatible XML Version for " + GetSerializableName() + ": Not Version 1.");
350  }
351  }else{
352  MEZZ_EXCEPTION(ExceptionBase::II_IDENTITY_INVALID_EXCEPTION,"Attempting to deserialize a " + GetSerializableName() + ", found a " + String(OneNode.Name()) + ".");
353  }
354 
355  }
356 
357  /// @brief get the name of this class for serialization purposes
358  /// @return A String containing "BezierInterpolator"
360  { return String("BezierInterpolator"); }
361  };
362 
363  /// @brief If something specifically needs the linear interpolator for T they should use this.
364  /// @details This is with be a cubic spline where applicable, and will be
365  /// more smooth that the others, and be at least as intuitive as the linear version:
366  /// - Data points, will be valid interpolated values.
367  /// - There are no "Corners".
368  /// - Execution time is O^N.
369  /// - This shape defined by interpolating a set of these *will* leave a Convex Hull (or Axis
370  /// Aligned Bounding Box) that could contain the data.
371  /// - Will be able to interpolated arbitrary sets of data points.
372  /// @warning This can interpolate cubic splines, but it cannot be used with the track at
373  /// present.
374  template <typename T>
376  {
377  public:
378  /// @brief The type this will interpolate
379  /// @note All Interpolators need to declare an InterpolatableType
381  /// @brief The storage for type for a cubic spline
383 
384  /// @brief Calculates the desired location on a cubic spline
385  /// @param Begin An iterator to the beginning of points to interpolate
386  /// @param End An iterator to the end of a data series, not one passed it.
387  /// @param Location A value between 0 and 1, that indicate how far along the curve the
388  /// data point to retrieve is
389  /// @return This will return an value along a curve that passes smoothly through all the
390  /// points passed.
391  template<typename TIterator>
392  static T Interpolate(TIterator Begin, TIterator End, Real Location)
393  {
394  /*std::vector<T> Points;
395  std::cout << "Unknown Type : " << typeid(TIterator).name() << std::endl
396  << "Vector<T> : " << typeid(std::vector<T>).name() << std::endl
397  << "Vector<T>::iterator : " << typeid(typename std::vector<T>::iterator).name() << std::endl
398  << "Storage : " << typeid(Storage).name() << std::endl
399  << "Storage::iterator : " << typeid(typename Storage::iterator).name() << std::endl
400  << "Storage::const_iterator : " << typeid(typename Storage::const_iterator).name() << std::endl
401  << "Is the unknown type a Storage::const_iterator? " << (typeid(typename Storage::const_iterator)==typeid(TIterator)) << std::endl
402  ;
403  Points.insert(Points.end(),Begin,End);// */
404  std::vector<T> Points(Begin, End);
405  std::vector<Real> Spacing(Points.size());
406  Real JumpSize = 1/PreciseReal(Points.size()-1);
407  Real CurrentJump=0;
408  for(std::vector<Real>::iterator Iter=Spacing.begin();
409  Iter!=Spacing.end();
410  Iter++)
411  {
412  *Iter=CurrentJump;
413  CurrentJump+=JumpSize;
414  }
415 
416  CubicSpline<Real,T> Spliney(Spacing,Points);
417  return Spliney.interpolate(Location);
418  }
419  };
420 
421 
422 } // /namespace Mezzanine
423 
424 
425 #ifndef SWIG
426 
427 /// @brief Used to Serialize an Mezzanine::LinearInterpolator to a human readable stream
428 /// @details The current XML format is extremely simple because there no data: 'c'.
429 /// @param Lint The Mezzanine::LinearInterpolator to be converted to characters.
430 /// @param stream The place to send the characters, that define the Mezzanine::LinearInterpolator.
431 /// @return Get an std::ostream that was written to, this allow chaining of the << operators.
432 template<typename T>
433 std::ostream& operator << (std::ostream& stream, const Mezzanine::LinearInterpolator<T>& Lint)
434 {
435  Serialize(stream,Lint);
436  return stream;
437 }
438 
439 /// @brief Used to de-serialize an Mezzanine::LinearInterpolator from a stream
440 /// @details This does primarily type checking most interpolators have no data
441 /// @param Lint The Mezzanine::LinearInterpolator that will accept the values from the xml
442 /// @param stream The place to get the characters from, that define the
443 /// @ref Mezzanine::LinearInterpolator.
444 /// @return Get an std::ostream that was read from, this allow chaining of the >> operators.
445 /// @throw Can throw any exception that any function in the Mezzanine::xml namespace could throw in
446 /// addition to a @ref Mezzanine::ExceptionBase if the serialization version doesn't match.
447 template<typename T>
448 std::istream& operator >> (std::istream& stream, Mezzanine::LinearInterpolator<T>& Lint)
449  { return DeSerialize(stream, Lint); }
450 
451 
452 /// @brief Used to Serialize an Mezzanine::BezierInterpolator to a human readable stream
453 /// @details The current XML format is extremely simple because there no data: 'c'.
454 /// @param Lint The Mezzanine::BezierInterpolator to be converted to characters.
455 /// @param stream The place to send the characters, that define the Mezzanine::BezierInterpolator.
456 /// @return Get an std::ostream that was written to, this allow chaining of the << operators.
457 template<typename T>
458 std::ostream& operator << (std::ostream& stream, const Mezzanine::BezierInterpolator<T>& Lint)
459 {
460  Serialize(stream,Lint);
461  return stream;
462 }
463 
464 /// @brief Used to de-serialize an Mezzanine::BezierInterpolator from a stream
465 /// @details This does primarily type checking most interpolators have no data
466 /// @param Lint The Mezzanine::BezierInterpolator that will accept the values from the xml
467 /// @param stream The place to get the characters from, that define the
468 /// Mezzanine::BezierInterpolator.
469 /// @return Get an std::ostream that was read from, this allow chaining of the >> operators.
470 /// @throw Can throw any exception that any function in the @ref Mezzanine::XML namespace could
471 /// throw in addition to a @ref Mezzanine::ExceptionBase if the serialization version doesn't match.
472 template<typename T>
473 std::istream& operator >> (std::istream& stream, Mezzanine::BezierInterpolator<T>& Lint)
474  { return DeSerialize(stream, Lint); }
475 
476 #endif
477 
478 #endif // Include guard
static T GetInterpolatedFromMultiple(TIterator Begin, TIterator End, Real Location)
Handles Interpolation of multiple points.
Definition: interpolator.h:146
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
A light-weight handle for manipulating attributes in DOM tree.
Definition: attribute.h:74
CubicSpline< Real, InterpolatableType > Storage
The storage for type for a cubic spline.
Definition: interpolator.h:382
A simple functor for interpolating data points in a simple way.
Definition: interpolator.h:78
static void ProtoDeSerialize(const XML::Node &OneNode)
This does not create or change the object it deserializes, but it does verify type info...
Definition: interpolator.h:336
static T Interpolate(TIterator Begin, TIterator End, Real Location)
Calculates the desired location on a cubic spline.
Definition: interpolator.h:392
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Definition: exception.h:3048
All the definitions for datatypes as well as some basic conversion functions are defined here...
std::ostream & Serialize(std::ostream &Stream, const T &Converted, const String &Indent=String(""))
Convert any class that supports serialization or has a serializer to a string of chars in a stream...
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
Definition: exception.h:112
const Char8 * AsString(const Char8 *def="") const
Attempts to convert the value of the attribute to a String and returns the results.
static void ProtoSerialize(XML::Node &CurrentRoot)
Append a node for with enough information to deserialize to the passed node.
Definition: interpolator.h:309
T InterpolatableType
The type this will interpolate.
Definition: interpolator.h:380
This implements the exception hiearchy for Mezzanine.
A simple functor for interpolating data points in a simple way.
Definition: interpolator.h:261
std::vector< InterpolatableType > Storage
The storage to use with thison tracks.
Definition: interpolator.h:268
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
The interface for serialization.
bool SetValue(const Char8 *rhs)
Set the value of this.
static String GetSerializableName()
get the name of this class for serialization purposes
Definition: interpolator.h:244
static T Interpolate(TIterator Begin, TIterator End, Real Location)
Get a value at a given location between two others.
Definition: interpolator.h:290
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
Thrown when a passed parameter is checked at runtime and not in the expected range.
Definition: exception.h:110
T InterpolatableType
The type this will interpolate.
Definition: interpolator.h:83
static String GetSerializableName()
get the name of this class for serialization purposes
Definition: interpolator.h:359
std::istream & DeSerialize(std::istream &Stream, T &Converted)
Deserialize the next xml tag in the stream into a specific in memory class instance.
std::vector< InterpolatableType > Storage
The storage to use with thison tracks.
Definition: interpolator.h:85
Thrown when the identity string wasn't valid at all.
Definition: exception.h:93
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
static void ProtoSerialize(XML::Node &CurrentRoot)
Append a node for with enough information to deserialize to the passed node.
Definition: interpolator.h:194
static T InterpolateMath(T Begin, T End, Real Location)
Get a value at a given location between exactly two others.
Definition: interpolator.h:92
static T Interpolate(TIterator Begin, TIterator End, Real Location)
This will interpolates data point with GetInterpolatedFromMultiple or InterpolateMath as required...
Definition: interpolator.h:176
static void ProtoDeSerialize(const XML::Node &OneNode)
This does not create or change the object it deserializes, but it does verify type info...
Definition: interpolator.h:221
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
double PreciseReal
A Real number that is at least as precise as the Real and could be considerably moreso, perhaps Doubly precise. This type might be poorly aligned but very precise.
Definition: datatypes.h:146
A class for interpolating data with arbitrary.
Definition: cubicspline.h:109
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
std::istream & operator>>(std::istream &stream, Mezzanine::LinearInterpolator< T > &Lint)
Used to de-serialize an Mezzanine::LinearInterpolator from a stream.
Definition: interpolator.h:448
const Char8 * Name() const
ptrdiff_tGet the name of this Node.
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.
T InterpolatableType
The type this will interpolate.
Definition: interpolator.h:266
If something specifically needs the linear interpolator for T they should use this.
Definition: interpolator.h:375