summaryrefslogtreecommitdiffhomepage
path: root/facetracknoir/lerp.hpp
diff options
context:
space:
mode:
authorDonovan Baarda <abo@minkirri.apana.org.au>2014-10-15 14:07:20 +1100
committerDonovan Baarda <abo@minkirri.apana.org.au>2014-10-15 14:07:20 +1100
commitdbd04e283082ab869a22abf03c4c6280b03935bb (patch)
tree3951c6f91f76047e655f35e04db4eecd576c49df /facetracknoir/lerp.hpp
parentd880464fbe9180aefde94594330126e115066dc3 (diff)
parent051a2e4392bc75b246cc5cb897ae0bbb1f92042e (diff)
Merge branch 'unstable' of https://github.com/opentrack/opentrack into dev/kalman
Conflicts: ftnoir_filter_kalman/ftnoir_filter_kalman.h
Diffstat (limited to 'facetracknoir/lerp.hpp')
-rw-r--r--facetracknoir/lerp.hpp60
1 files changed, 0 insertions, 60 deletions
diff --git a/facetracknoir/lerp.hpp b/facetracknoir/lerp.hpp
deleted file mode 100644
index 0123832a..00000000
--- a/facetracknoir/lerp.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-#pragma once
-
-#include "facetracknoir/timer.hpp"
-#include <algorithm>
-#include <cmath>
-
-class lerp {
-private:
- static const constexpr double eps = 1e-2;
- double last[2][6], cam[6], dt;
- Timer t;
-public:
- lerp() :
- last { {0,0,0,0,0,0}, {0,0,0,0,0,0} }, cam {0,0,0,0,0,0}, dt(1)
- {
- }
- bool idempotentp(const double* input)
- {
- for (int i = 0; i < 6; i++)
- {
- double diff = fabs(cam[i] - input[i]);
- if (diff > eps)
- return false;
- }
- return true;
- }
-
- void write(const double* cam_, const double* input, double* output)
- {
- const double q = t.elapsed();
- const double d = q/dt;
-
- bool idem = idempotentp(cam_);
-
- if (!idem)
- {
- dt = q;
- t.start();
- }
-
- const double c = std::max(std::min(1.0, d), 0.0);
-
- if (!idem)
- for (int i = 0; i < 6; i++)
- {
- last[1][i] = last[0][i];
- last[0][i] = input[i];
- cam[i] = cam_[i];
- }
-
- for (int i = 0; i < 6; i++)
- output[i] = last[1][i] + (last[0][i] - last[1][i]) * c;
- }
-
- void get_state(double* state)
- {
- for (int i = 0; i < 6; i++)
- state[i] = last[0][i];
- }
-};