Skip to content

Commit

Permalink
tracker/test: test continuous step from -180 to +180
Browse files Browse the repository at this point in the history
  • Loading branch information
sthalik committed Jan 16, 2017
1 parent 734d02b commit 3094ef1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
18 changes: 8 additions & 10 deletions tracker-test/test.cpp
Expand Up @@ -56,23 +56,21 @@ void test_tracker::data(double *data)
#endif
for (int i = 0; i < 6; i++)
{
double x = fmod(last_x[i] + incr[i] * d2r * dt, 2 * M_PI);
double x = last_x[i] + incr[i] * dt;
if (x > 180)
x = -360 + x;
else if (x < -180)
x = 360 + x;
x = copysign(fmod(fabs(x), 360), x);
last_x[i] = x;

if (i >= 3)
{
#ifdef DISCONTINUITY
if (x > pi + pi/2)
x -= M_PI;
else if (x > pi/2 && x < pi)
x += M_PI;
#endif

data[i] = sin(x) * 180;
data[i] = x;
}
else
{
data[i] = sin(x) * 100;
data[i] = x * 100/180.;
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions tracker-test/test.h
Expand Up @@ -14,9 +14,6 @@ class test_tracker : public ITracker
void data(double *data) override;

private:
static constexpr double r2d = 180 / M_PI;
static constexpr double d2r = M_PI / 180;

static const double incr[6];
double last_x[6];
Timer t;
Expand Down

0 comments on commit 3094ef1

Please sign in to comment.