-
Notifications
You must be signed in to change notification settings - Fork 0
/
vxVector_UT.cpp
86 lines (69 loc) · 1.63 KB
/
vxVector_UT.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
*
* file vxVector_UT.cpp
*
* This test file is a part of VoxelBrain software.
*
* (c) Nanyang Technological University
*
* Author: Konstantin Levinski
*
*/
#include <gtest/gtest.h>
#include "vxVector.h"
TEST(MAIN, Vector){
};
TEST(MAIN, BasicOperators){
float v_array[] = {1.0f, 4.0f, 3.0f };
V3f a(1.0f, 2.0f, 3.3f);
V3f x(1.0f, 1.0f, 3.3f);
V3f y(1.0f, 2.0f, 3.0f);
V3i iv(23,32,44);
V3f v(v_array);
V3f b(a);
V3f d; d = a;
EXPECT_EQ(iv[0], 23);
EXPECT_EQ(iv[1], 32);
EXPECT_EQ(iv[2], 44);
EXPECT_FLOAT_EQ(a[0], 1.0f);
EXPECT_FLOAT_EQ(a[1], 2.0f);
EXPECT_FLOAT_EQ(a[2], 3.3f);
for (int i = 0; i < 3; ++i)
{
EXPECT_FLOAT_EQ(v[i], v_array[i]);
}
EXPECT_FLOAT_EQ(1.0f, a.distance2(x));
EXPECT_FLOAT_EQ(0.0f, a.distance2(b));
EXPECT_TRUE(a==b);
EXPECT_FALSE(a==x);
EXPECT_TRUE(a!=x);
};
TEST(MAIN, Cross){
V3f a(1.0f, 0.0f, 0.0f);
V3f b(0.0f, 1.0f, 0.0f);
V3f c(0.0f, 0.0f, 1.0f);
EXPECT_TRUE(a.cross(b) == c);
EXPECT_TRUE(b.cross(c) == a);
EXPECT_TRUE(c.cross(a) == b);
};
TEST(MAIN, Rotation){
V3f a(1.0f, 1.0f, 1.0f);
/*
say("X", rot_x(a, -PI/2.0f));
say("Y", rot_y(a, -PI/2.0f));
say("Z", rot_z(a, -PI/2.0f));
*/
EXPECT_TRUE(V3f(1.0f, -1.0f, 1.0f) == rot_x(a, PI/2.0f));
EXPECT_TRUE(V3f(1.0f, 1.0f, -1.0f) == rot_y(a, PI/2.0f));
EXPECT_TRUE(V3f(-1.0f, 1.0f, 1.0f) == rot_z(a, PI/2.0f));
};
TEST(MAIN, ortoNormalize){
V3f a(1.0f, 2.0f, 3.3f);
V3f b(1.0f, 1.0f, 3.3f);
V3f c(1.0f, 2.0f, 3.0f);
ortoNormalize(a,b,c);
EXPECT_TRUE(c == a.cross(b));
EXPECT_TRUE(a == b.cross(c));
EXPECT_TRUE(b == c.cross(a));
};
//End of vxVector_UT.cpp