5 #define SQRT_2 1.4142135623730951f 7 TEST(VectorTest, Rotations)
9 unsigned rotation_count = 0;
11 #define TEST_ROTATION(rotation, _x, _y, _z) { \ 12 const float accuracy = 1.0e-6; \ 13 Vector3f v(1, 1, 1); \ 15 Vector3f expected(_x, _y, _z); \ 16 EXPECT_NEAR(expected.length(), v.length(), accuracy); \ 17 EXPECT_FLOAT_EQ(expected.x, v.x); \ 18 EXPECT_FLOAT_EQ(expected.y, v.y); \ 19 EXPECT_FLOAT_EQ(expected.z, v.z); \ 65 EXPECT_EQ(
ROTATION_MAX, rotation_count) <<
"All rotations are expect to be tested";
81 EXPECT_FALSE(
is_equal(0.1, 0.10001));
82 EXPECT_FALSE(
is_equal(0.1, -0.1001));
84 EXPECT_FALSE(
is_equal(1.
f, 1.
f + FLT_EPSILON));
85 EXPECT_TRUE(
is_equal(1.
f, 1.
f + FLT_EPSILON / 2.
f));
86 EXPECT_TRUE(
is_equal(1.
f, (
float)(1.
f - DBL_EPSILON)));
89 EXPECT_FALSE(
is_equal(
double(1.), 1 + 2 * std::numeric_limits<double>::epsilon()));
92 EXPECT_TRUE(
is_equal(1.
f, (
float)(1. + std::numeric_limits<double>::epsilon())));
101 EXPECT_EQ(0.
f, sq_0);
102 EXPECT_EQ(1.
f, sq_1);
103 EXPECT_EQ(4.
f, sq_2);
108 float norm_1 =
norm(1, 4.2);
109 float norm_2 =
norm(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
110 float norm_3 =
norm(0, 5.3);
111 float norm_4 =
norm(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
112 float norm_5 =
norm(3,4);
113 float norm_6 =
norm(4,3,12);
115 EXPECT_FLOAT_EQ(norm_1, 4.3174066
f);
116 EXPECT_EQ(norm_2, 4.
f);
117 EXPECT_EQ(norm_3, 5.3
f);
118 EXPECT_EQ(norm_4, 0.
f);
119 EXPECT_EQ(norm_5, 5.
f);
120 EXPECT_EQ(norm_6, 13.
f);
126 for (
int i = 0; i < 1000; i++) {
131 }
else if (i > 500) {
142 for (
int i = 0; i <= 1000; i++) {
159 for (
int i = 0; i <= 2000; i++) {
189 for (int32_t i = 0; i < 36000; i += 100) {
194 }
else if (i == 18000) {
228 for (int32_t i = 0; i <= 36000; i += 100) {
233 }
else if (i < 36000) {
237 }
else if (i == 36000) {
264 const float accuracy = 1.0e-5;
273 const float accuracy = 1.0e-5;
float norm(const T first, const U second, const Params... parameters)
#define TEST_ROTATION(rotation, _x, _y, _z)
int16_t constrain_int16(const int16_t amt, const int16_t low, const int16_t high)
auto wrap_360_cd(const T angle) -> decltype(wrap_360(angle, 100.f))
auto wrap_180_cd(const T angle) -> decltype(wrap_180(angle, 100.f))
float wrap_PI(const T radian)
bool is_zero(const T fVal1)
int32_t constrain_int32(const int32_t amt, const int32_t low, const int32_t high)
TEST(VectorTest, Rotations)
float constrain_float(const float amt, const float low, const float high)
float wrap_2PI(const T radian)
std::enable_if< std::is_integral< typename std::common_type< Arithmetic1, Arithmetic2 >::type >::value,bool >::type is_equal(const Arithmetic1 v_1, const Arithmetic2 v_2)
T constrain_value(const T amt, const T low, const T high)