interface changes
added new data-strcutures for new sensors new helper methods fixed some issues
This commit is contained in:
@@ -9,5 +9,6 @@
|
||||
#include "distribution/Region.h"
|
||||
#include "distribution/Triangle.h"
|
||||
#include "distribution/NormalN.h"
|
||||
#include "distribution/Rectangular.h"
|
||||
|
||||
#endif // DISTRIBUTIONS_H
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "../Assertions.h"
|
||||
#include "../Exception.h"
|
||||
#include "../data/Timestamp.h"
|
||||
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
@@ -49,7 +50,7 @@ public:
|
||||
|
||||
// interpolate
|
||||
const int idx1 = (idx2 > 0) ? (idx2 - 1) : (idx2);
|
||||
const float percent = (key - entries[idx1].key) / (float) (entries[idx2].key - entries[idx1].key);
|
||||
const float percent = getPercent(key, entries[idx1].key, entries[idx2].key); //(key - entries[idx1].key) / (float) (entries[idx2].key - entries[idx1].key);
|
||||
const Value res = entries[idx1].value + (entries[idx2].value - entries[idx1].value) * percent;
|
||||
return res;
|
||||
|
||||
@@ -57,6 +58,16 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
/** special interpolation for the timestamp class */
|
||||
static inline float getPercent(const Timestamp key, const Timestamp t1, const Timestamp t2) {
|
||||
return (key - t1).ms() / (float) (t2 - t1).ms();
|
||||
}
|
||||
|
||||
/** interpolation for generic datatypes [int, float, double, ..] */
|
||||
template <typename T> static inline float getPercent(const T key, const T t1, const T t2) {
|
||||
return (key - t1) / (float) (t2 - t1);
|
||||
}
|
||||
|
||||
/** get the nearest index for the given key */
|
||||
int getIdxAfter(const Key key) const {
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ private:
|
||||
std::vector<T> values;
|
||||
|
||||
/** track the current sum of the vector's values */
|
||||
T curSum = 0;
|
||||
T curSum;
|
||||
|
||||
/** the number of elements to average */
|
||||
int size;
|
||||
@@ -19,7 +19,7 @@ private:
|
||||
public:
|
||||
|
||||
/** ctor */
|
||||
MovingAVG(const int size) : size(size) {;}
|
||||
MovingAVG(const int size) : curSum(), size(size) {;}
|
||||
|
||||
/** add a new value */
|
||||
void add(const T val) {
|
||||
|
||||
Reference in New Issue
Block a user