From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a03643.html | 498 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 498 insertions(+) create mode 100644 docs/doxygen/nel/a03643.html (limited to 'docs/doxygen/nel/a03643.html') diff --git a/docs/doxygen/nel/a03643.html b/docs/doxygen/nel/a03643.html new file mode 100644 index 00000000..d78415cf --- /dev/null +++ b/docs/doxygen/nel/a03643.html @@ -0,0 +1,498 @@ + + +NeL: TemplateNLMISC::CValueSmootherTemplate< T > class Reference + + + +
+

NLMISC::CValueSmootherTemplate< T > Class Template Reference

#include <value_smoother.h> +

+


Detailed Description

+

template<class T>
+ class NLMISC::CValueSmootherTemplate< T >

+ +A smoother of values.
Author:
Lionel Berenguier

+Nevrax France

+
Date:
2001
+ +

+ +

+Definition at line 45 of file value_smoother.h. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Member Functions

void addValue (T dt)
 add a new value to be smoothed.

 CValueSmootherTemplate (uint n=16)
 Constructor.

const std::vector< T > & getLastFrames () const
uint getNumFrame () const
getSmoothValue () const
 get the smoothed value.

void init (uint n)
 reset the ValueSmoother, and set the number of frame to smooth.

void reset ()
 reset only the ValueSmoother


Private Attributes

uint _CurFrame
_FrameSum
std::vector< T > _LastFrames
uint _NumFrame
+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
NLMISC::CValueSmootherTemplate< T >::CValueSmootherTemplate uint  n = 16  )  [inline, explicit]
+
+ + + + + +
+   + + +

+Constructor. +

+ +

+Definition at line 50 of file value_smoother.h. +

+

00051         {
+00052                 init(n);
+00053         }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
void NLMISC::CValueSmootherTemplate< T >::addValue dt  )  [inline]
+
+ + + + + +
+   + + +

+add a new value to be smoothed. +

+ +

+Definition at line 80 of file value_smoother.h. +

+

00081         {
+00082                 if (_LastFrames.empty())
+00083                         return;
+00084 
+00085                 // update the frame sum. NB: see init(), at start, array is full of 0. so it works even for un-inited values.
+00086                 _FrameSum-= _LastFrames[_CurFrame];
+00087                 _FrameSum+= dt;
+00088                 
+00089                 // backup this value in the array.
+00090                 _LastFrames[_CurFrame]= dt;
+00091                 
+00092                 // next frame.
+00093                 _CurFrame++;
+00094 //              _CurFrame%=_LastFrames.size();
+00095                 if (_CurFrame >= _LastFrames.size())
+00096                         _CurFrame -= _LastFrames.size();
+00097                 
+00098                 // update the number of frames added.
+00099                 _NumFrame++;
+00100                 _NumFrame= std::min(_NumFrame, (uint)_LastFrames.size());
+00101         }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
const std::vector<T>& NLMISC::CValueSmootherTemplate< T >::getLastFrames  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 117 of file value_smoother.h. +

+

00118         {
+00119                 return _LastFrames;
+00120         }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
uint NLMISC::CValueSmootherTemplate< T >::getNumFrame  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 112 of file value_smoother.h. +

+

00113         {
+00114                 return _NumFrame;
+00115         }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class T>
T NLMISC::CValueSmootherTemplate< T >::getSmoothValue  )  const [inline]
+
+ + + + + +
+   + + +

+get the smoothed value. +

+ +

+Definition at line 104 of file value_smoother.h. +

+

00105         {
+00106                 if(_NumFrame>0)
+00107                         return T(_FrameSum / _NumFrame);
+00108                 else
+00109                         return T(0);
+00110         }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
void NLMISC::CValueSmootherTemplate< T >::init uint  n  )  [inline]
+
+ + + + + +
+   + + +

+reset the ValueSmoother, and set the number of frame to smooth. +

+ +

+Definition at line 56 of file value_smoother.h. +

+Referenced by NLMISC::CValueSmootherTemplate< bool >::CValueSmootherTemplate(), and NLMISC::CValueSmootherTemplate< float >::CValueSmootherTemplate(). +

+

00057         {
+00058                 // reset all the array to 0.
+00059                 _LastFrames.clear();
+00060 
+00061                 if (n > 0)
+00062                         _LastFrames.resize(n, 0);
+00063                 
+00064                 _CurFrame = 0;
+00065                 _NumFrame = 0;
+00066                 _FrameSum = 0;
+00067         }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class T>
void NLMISC::CValueSmootherTemplate< T >::reset void   )  [inline]
+
+ + + + + +
+   + + +

+reset only the ValueSmoother +

+ +

+Definition at line 70 of file value_smoother.h. +

+

00071         {
+00072                 std::fill(_LastFrames.begin(), _LastFrames.end(), T(0));
+00073                 
+00074                 _CurFrame = 0;
+00075                 _NumFrame = 0;
+00076                 _FrameSum = 0;
+00077         }
+
+


Field Documentation

+

+ + + + +
+ + + + + +
+template<class T>
uint NLMISC::CValueSmootherTemplate< T >::_CurFrame [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 124 of file value_smoother.h.

+

+ + + + +
+ + + + + +
+template<class T>
T NLMISC::CValueSmootherTemplate< T >::_FrameSum [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 126 of file value_smoother.h.

+

+ + + + +
+ + + + + +
+template<class T>
std::vector<T> NLMISC::CValueSmootherTemplate< T >::_LastFrames [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 123 of file value_smoother.h.

+

+ + + + +
+ + + + + +
+template<class T>
uint NLMISC::CValueSmootherTemplate< T >::_NumFrame [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 125 of file value_smoother.h.

+


The documentation for this class was generated from the following file: +
Generated on Tue Mar 16 13:40:10 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1