diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-06-19 13:58:41 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-06-19 13:58:41 +0200 |
commit | 70d5fdedd5fd6d88d2d7453ac49af6aa75cbd5fb (patch) | |
tree | 012f84a050764a3b651e752791d92a0f56d60f53 /tracker-test/test.cpp | |
parent | a3e8c8bae2467b7fad43b9d6068defb7b54dd534 (diff) |
tracker/test: test emitting NaN values
Diffstat (limited to 'tracker-test/test.cpp')
-rw-r--r-- | tracker-test/test.cpp | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/tracker-test/test.cpp b/tracker-test/test.cpp index 32ff5336..b6cc742e 100644 --- a/tracker-test/test.cpp +++ b/tracker-test/test.cpp @@ -32,6 +32,10 @@ void FTNoIR_Tracker::start_tracker(QFrame*) t.start(); } +#ifdef EMIT_NAN +# include <cstdlib> +#endif + void FTNoIR_Tracker::data(double *data) { using std::fmod; @@ -42,28 +46,36 @@ void FTNoIR_Tracker::data(double *data) const double dt = t.elapsed_seconds(); t.start(); - for (int i = 0; i < 6; i++) +#ifdef EMIT_NAN + if ((rand()%4) == 0) { - double x = fmod(last_x[i] + incr[i] * d2r * dt, - 2 * pi); - last_x[i] = x; - - if (i >= 3) + for (int i = 0; i < 6; i++) + data[i] = 0./0.; + } + else +#endif + for (int i = 0; i < 6; i++) { -#if 0 - if (x > pi + pi/2) - x -= pi; - else if (x > pi/2 && x < pi) - x += pi; + double x = fmod(last_x[i] + incr[i] * d2r * dt, + 2 * pi); + last_x[i] = x; + + if (i >= 3) + { +#ifdef DISCONTINUITY + if (x > pi + pi/2) + x -= pi; + else if (x > pi/2 && x < pi) + x += pi; #endif - data[i] = sin(x) * 180; - } - else - { - data[i] = sin(x) * 100; + data[i] = sin(x) * 180; + } + else + { + data[i] = sin(x) * 100; + } } - } } TrackerControls::TrackerControls() |