MAK Data Logger API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qtFloatMath.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #ifndef qtFloatMath_H_
11 #define qtFloatMath_H_
12 
13 #include <lgrGui/lgrGui.h>
14 
15 #include <QtCore/QPoint>
16 #include <QtCore/QRect>
17 #include <math.h>
18 
19 #include <limits.h>
20 #define DT_ROUND(x) (((x) < LONG_MIN-0.5 || (x) > LONG_MAX+0.5) ? 0 : ((x)>=0?(int)((x)+0.5):(int)((x)-0.5)))
21 
22 namespace MAKLogger
23 {
28  {
29  public:
30 
31  DtValueSmoother(int valuesToBuffer,double init)
32  {
33  myValues = new double[valuesToBuffer];
34  myBufferSize = valuesToBuffer;
35  for(int i = 0;i < myBufferSize;++i)
36  {
37  myValues[i] = init;
38  }
39 
40  }
41 
43  {
44  delete[] myValues;
45  }
46 
47  void addValue(double value)
48  {
49  for(int i = 1;i < myBufferSize;++i)
50  {
51  myValues[i-1] = myValues[i];
52  }
53  myValues[myBufferSize-1] = value;
54  }
55 
57  double getSmoothedValue()
58  {
60  double deltaD = 0.0;
61  for(int i = 1;i < myBufferSize;++i)
62  {
63  deltaD += myValues[i] - myValues[i-1];
64  }
65  deltaD /= (myBufferSize-1);
66 
68  double newValue = 0.0;
69  for(int j = 0;j < myBufferSize;++j)
70  {
71  newValue += myValues[j] + ((myBufferSize - j) * deltaD);
72  }
73  newValue /= myBufferSize;
74  return newValue;
75  }
76 
77  protected:
78  double* myValues;
80  };
81 
82 
83 
84 }
85 
86 #endif
87 

Document ID: Generated on Thu Apr 7 20:50:59 EDT 2016 from SVN revision 163818
Copyright © 2005-2012 VT MÄK. All Rights Reserved (www.mak.com)