homogeneous_points.cpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Includes
11 *****************************************************************************/
12 
13 #include <gtest/gtest.h>
14 #include "../../include/ecl/geometry/homogeneous_point.hpp"
15 
16 /*****************************************************************************
17 ** Using
18 *****************************************************************************/
19 
20 using ecl::linear_algebra::Vector3d;
21 using ecl::linear_algebra::Vector4d;
22 using ecl::linear_algebra::Vector4f;
26 
27 /*****************************************************************************
28 ** Tests
29 *****************************************************************************/
30 
31 TEST(HomogeneousPointTests,construct) {
32  HomogeneousPointd point(0.1,0.2,0.3);
33  EXPECT_EQ(0.1,point.x());
34  EXPECT_EQ(0.2,point.y());
35  EXPECT_EQ(0.3,point.z());
36  Vector4d v; v << 0.1, 0.2, 0.3, 1.0;
37  HomogeneousPointd p2(v);
38  EXPECT_EQ(0.1,p2.x());
39  EXPECT_EQ(0.2,p2.y());
40  EXPECT_EQ(0.3,p2.z());
41  Vector3d v3; v3 << 1.0, 2.0, 3.0;
42  HomogeneousPointd p3(v3);
43  EXPECT_EQ(1.0,p3.x());
44  EXPECT_EQ(2.0,p3.y());
45  EXPECT_EQ(3.0,p3.z());
46 }
47 
48 TEST(HomogeneousPointTests,assignment) {
49  HomogeneousPointf point;
50  point << 1.0, 2.0, 3.0, 1.0;
51  EXPECT_EQ(1.0,point.x());
52  EXPECT_EQ(2.0,point.y());
53  EXPECT_EQ(3.0,point.z());
54  point.x(1.0);
55  point.y(2.0);
56  point.z(3.0);
57  EXPECT_EQ(1.0,point.x());
58  EXPECT_EQ(2.0,point.y());
59  EXPECT_EQ(3.0,point.z());
60  Vector4f v; v << 1.0, 2.0, 3.0, 1.0;
61  point = v;
62  EXPECT_EQ(1.0,point.x());
63  EXPECT_EQ(2.0,point.y());
64  EXPECT_EQ(3.0,point.z());
65 }
66 
67 TEST(HomogeneousPointTests,vectorHandle) {
68  HomogeneousPointd point;
69  point << 1.0, 2.0, 3.0, 1.0;
70  const Vector4d& v = point.positionVector();
71  EXPECT_EQ(1.0,v[0]);
72  EXPECT_EQ(2.0,v[1]);
73  EXPECT_EQ(3.0,v[2]);
74 }
75 
76 TEST(HomogeneousPointTests,constAccessors) {
77  HomogeneousPointd point;
78  point << 1.0, 2.0, 3.0, 1.0;
79  const int cx = point.x();
80  const int cy = point.y();
81  const int cz = point.z();
82  EXPECT_EQ(1.0,cx);
83  EXPECT_EQ(2.0,cy);
84  EXPECT_EQ(3.0,cz);
85 }
86 
87 /*****************************************************************************
88 ** Main program
89 *****************************************************************************/
90 
91 int main(int argc, char **argv) {
92  testing::InitGoogleTest(&argc,argv);
93  return RUN_ALL_TESTS();
94 }
95 
96 
int main(int argc, char **argv)
HomogeneousPoint< double > HomogeneousPointd
Eigen style convenience handle for homogeneous points in double format.
HomogeneousPoint< float > HomogeneousPointf
Eigen style convenience handle for homogeneous points in float format.
TEST(HomogeneousPointTests, construct)
Dummy parent class for Homogenous points.


ecl_geometry
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:37