00001
00009
00010
00011
00012
00013 #include <gtest/gtest.h>
00014 #include "../../include/ecl/geometry/homogeneous_point.hpp"
00015
00016
00017
00018
00019
00020 using ecl::linear_algebra::Vector3d;
00021 using ecl::linear_algebra::Vector4d;
00022 using ecl::linear_algebra::Vector4f;
00023 using ecl::HomogeneousPoint;
00024 using ecl::HomogeneousPointf;
00025 using ecl::HomogeneousPointd;
00026
00027
00028
00029
00030
00031 TEST(HomogeneousPointTests,construct) {
00032 HomogeneousPointd point(0.1,0.2,0.3);
00033 EXPECT_EQ(0.1,point.x());
00034 EXPECT_EQ(0.2,point.y());
00035 EXPECT_EQ(0.3,point.z());
00036 Vector4d v; v << 0.1, 0.2, 0.3, 1.0;
00037 HomogeneousPointd p2(v);
00038 EXPECT_EQ(0.1,p2.x());
00039 EXPECT_EQ(0.2,p2.y());
00040 EXPECT_EQ(0.3,p2.z());
00041 Vector3d v3; v3 << 1.0, 2.0, 3.0;
00042 HomogeneousPointd p3(v3);
00043 EXPECT_EQ(1.0,p3.x());
00044 EXPECT_EQ(2.0,p3.y());
00045 EXPECT_EQ(3.0,p3.z());
00046 }
00047
00048 TEST(HomogeneousPointTests,assignment) {
00049 HomogeneousPointf point;
00050 point << 1.0, 2.0, 3.0, 1.0;
00051 EXPECT_EQ(1.0,point.x());
00052 EXPECT_EQ(2.0,point.y());
00053 EXPECT_EQ(3.0,point.z());
00054 point.x(1.0);
00055 point.y(2.0);
00056 point.z(3.0);
00057 EXPECT_EQ(1.0,point.x());
00058 EXPECT_EQ(2.0,point.y());
00059 EXPECT_EQ(3.0,point.z());
00060 Vector4f v; v << 1.0, 2.0, 3.0, 1.0;
00061 point = v;
00062 EXPECT_EQ(1.0,point.x());
00063 EXPECT_EQ(2.0,point.y());
00064 EXPECT_EQ(3.0,point.z());
00065 }
00066
00067 TEST(HomogeneousPointTests,vectorHandle) {
00068 HomogeneousPointd point;
00069 point << 1.0, 2.0, 3.0, 1.0;
00070 const Vector4d& v = point.positionVector();
00071 EXPECT_EQ(1.0,v[0]);
00072 EXPECT_EQ(2.0,v[1]);
00073 EXPECT_EQ(3.0,v[2]);
00074 }
00075
00076 TEST(HomogeneousPointTests,constAccessors) {
00077 HomogeneousPointd point;
00078 point << 1.0, 2.0, 3.0, 1.0;
00079 const int cx = point.x();
00080 const int cy = point.y();
00081 const int cz = point.z();
00082 EXPECT_EQ(1.0,cx);
00083 EXPECT_EQ(2.0,cy);
00084 EXPECT_EQ(3.0,cz);
00085 }
00086
00087
00088
00089
00090
00091 int main(int argc, char **argv) {
00092 testing::InitGoogleTest(&argc,argv);
00093 return RUN_ALL_TESTS();
00094 }
00095
00096