summaryrefslogtreecommitdiffhomepage
path: root/tracker-test/test.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-06-12 16:58:28 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-06-14 18:14:46 +0200
commit251d2c45a37da6fed01c1f37529c3cd899b434e6 (patch)
tree4a325cde6a3bba1557bc8384384f295ac74e3259 /tracker-test/test.cpp
parentaa635343aa5f4a84b9491ad8fb008bf17544a3fe (diff)
tracker/test: sine wave test tracker
Diffstat (limited to 'tracker-test/test.cpp')
-rw-r--r--tracker-test/test.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/tracker-test/test.cpp b/tracker-test/test.cpp
new file mode 100644
index 00000000..b9376c98
--- /dev/null
+++ b/tracker-test/test.cpp
@@ -0,0 +1,83 @@
+/* Copyright (c) 2014, Stanislaw Halik <sthalik@misaki.pl>
+
+ * Permission to use, copy, modify, and/or distribute this
+ * software for any purpose with or without fee is hereby granted,
+ * provided that the above copyright notice and this permission
+ * notice appear in all copies.
+ */
+
+#include "test.h"
+#include "opentrack/plugin-api.hpp"
+#include <cmath>
+
+#include <QDebug>
+
+const double FTNoIR_Tracker::incr[6] =
+{
+ 2, 3, 4,
+ 70, 5, 3
+};
+
+FTNoIR_Tracker::FTNoIR_Tracker() :
+ last_x { 0, 0, 0, 0, 0, 0 }
+{
+}
+
+FTNoIR_Tracker::~FTNoIR_Tracker()
+{
+}
+
+void FTNoIR_Tracker::start_tracker(QFrame*)
+{
+ t.start();
+}
+
+void FTNoIR_Tracker::data(double *data)
+{
+ using std::fmod;
+ using std::sin;
+ using std::fabs;
+ using std::copysign;
+
+ const double dt = t.elapsed_seconds();
+ t.start();
+
+ for (int i = 0; i < 6; i++)
+ {
+ double x = last_x[i] + incr[i] * d2r * dt;
+
+ x = fmod(x , 2 * pi);
+
+ last_x[i] = x;
+
+ if (x > pi + pi/2)
+ {
+ x -= pi;
+ }
+
+ double ret = sin(x) * 180;
+
+ data[i] = ret;
+ }
+}
+
+TrackerControls::TrackerControls()
+{
+ ui.setupUi(this);
+
+ connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
+ connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
+}
+
+void TrackerControls::doOK()
+{
+ //s.b->save();
+ close();
+}
+
+void TrackerControls::doCancel()
+{
+ close();
+}
+
+OPENTRACK_DECLARE_TRACKER(FTNoIR_Tracker, TrackerControls, FTNoIR_TrackerDll)