This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Indoor/tests/geo/TestAngle.cpp
2016-01-21 20:01:20 +01:00

62 lines
2.2 KiB
C++
Executable File

#ifdef WITH_TESTS
#include "../Tests.h"
#include "../../geo/Angle.h"
TEST(Angle, calc) {
ASSERT_EQ(0, Angle::getDEG_360(0,0, +1,0)); // to the right
ASSERT_EQ(90, Angle::getDEG_360(0,0, 0,+1)); // upwards
ASSERT_EQ(180, Angle::getDEG_360(0,0, -1,0)); // to the left
ASSERT_EQ(270, Angle::getDEG_360(0,0, 0,-1)); // downwards
ASSERT_EQ(45, Angle::getDEG_360(0,0, +1,+1)); // to the upper right
ASSERT_EQ(135, Angle::getDEG_360(0,0, -1,+1)); // to the upper left
ASSERT_EQ(225, Angle::getDEG_360(0,0, -1,-1)); // to the lower left
ASSERT_EQ(315, Angle::getDEG_360(0,0, +1,-1)); // to the lower right
}
TEST(Angle, diff) {
const float r = Angle::getRAD_2PI(0,0, +1,0); // to the right
const float u = Angle::getRAD_2PI(0,0, 0,+1); // upwards
const float l = Angle::getRAD_2PI(0,0, -1,0); // to the left
const float d = Angle::getRAD_2PI(0,0, 0,-1); // downwards
const float ur = Angle::getRAD_2PI(0,0, +1,+1); // to the upper right
const float ul = Angle::getRAD_2PI(0,0, -1,+1); // to the upper left
const float dl = Angle::getRAD_2PI(0,0, -1,-1); // to the lower left
const float dr = Angle::getRAD_2PI(0,0, +1,-1); // to the lower right
ASSERT_NEAR(M_PI_2, Angle::getDiffRAD_2PI_PI(r, u), 0.0001);
ASSERT_NEAR(M_PI_2, Angle::getDiffRAD_2PI_PI(u, r), 0.0001);
ASSERT_NEAR(M_PI_2, Angle::getDiffRAD_2PI_PI(u, l), 0.0001);
ASSERT_NEAR(M_PI_2, Angle::getDiffRAD_2PI_PI(l, u), 0.0001);
ASSERT_NEAR(M_PI_2, Angle::getDiffRAD_2PI_PI(l, d), 0.0001);
ASSERT_NEAR(M_PI_2, Angle::getDiffRAD_2PI_PI(d, l), 0.0001);
ASSERT_NEAR(M_PI_2, Angle::getDiffRAD_2PI_PI(d, r), 0.0001);
ASSERT_NEAR(M_PI_2, Angle::getDiffRAD_2PI_PI(r, d), 0.0001);
ASSERT_NEAR(M_PI_2, Angle::getDiffRAD_2PI_PI(ur, ul), 0.0001);
ASSERT_NEAR(M_PI_2, Angle::getDiffRAD_2PI_PI(ul, ur), 0.0001);
ASSERT_NEAR(M_PI_2, Angle::getDiffRAD_2PI_PI(ul, dl), 0.0001);
ASSERT_NEAR(M_PI_2, Angle::getDiffRAD_2PI_PI(dl, ul), 0.0001);
ASSERT_NEAR(M_PI_2, Angle::getDiffRAD_2PI_PI(dl, dr), 0.0001);
ASSERT_NEAR(M_PI_2, Angle::getDiffRAD_2PI_PI(dr, dl), 0.0001);
ASSERT_NEAR(M_PI_2, Angle::getDiffRAD_2PI_PI(dr, ur), 0.0001);
ASSERT_NEAR(M_PI_2, Angle::getDiffRAD_2PI_PI(ur, dr), 0.0001);
}
#endif