00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <gtest/gtest.h>
00031
00032 #include <swri_geometry_util/geometry_util.h>
00033
00034 TEST(IntersectionTests, ClosestPointToLinesInvalid)
00035 {
00036 tf::Vector3 point;
00037 ASSERT_FALSE(swri_geometry_util::ClosestPointToLines(
00038 tf::Vector3(1, 0, 0),
00039 tf::Vector3(1, 0, 0),
00040 tf::Vector3(0, 1, 0),
00041 tf::Vector3(1, 0, 1),
00042 point));
00043
00044 ASSERT_FALSE(swri_geometry_util::ClosestPointToLines(
00045 tf::Vector3(1, 0, 1),
00046 tf::Vector3(0, 1, 0),
00047 tf::Vector3(0, 0, 1),
00048 tf::Vector3(0, 0, 1),
00049 point));
00050
00051 ASSERT_FALSE(swri_geometry_util::ClosestPointToLines(
00052 tf::Vector3(0, 0, 0),
00053 tf::Vector3(10, 0, 0),
00054 tf::Vector3(20, 0, 0),
00055 tf::Vector3(30, 0, 0),
00056 point));
00057
00058 ASSERT_FALSE(swri_geometry_util::ClosestPointToLines(
00059 tf::Vector3(0, 0, 0),
00060 tf::Vector3(10, 0, 0),
00061 tf::Vector3(30, 0, 0),
00062 tf::Vector3(10, 0, 0),
00063 point));
00064
00065 ASSERT_FALSE(swri_geometry_util::ClosestPointToLines(
00066 tf::Vector3(0, 0, 0),
00067 tf::Vector3(10, 0, 0),
00068 tf::Vector3(20, 10, 10),
00069 tf::Vector3(30, 10, 10),
00070 point));
00071
00072
00073 ASSERT_FALSE(swri_geometry_util::ClosestPointToLines(
00074 tf::Vector3(0, 0, 0),
00075 tf::Vector3(10, 0, 0),
00076 tf::Vector3(30, 10, 10),
00077 tf::Vector3(10, 10, 10),
00078 point));
00079 }
00080
00081 TEST(IntersectionTests, ClosestPointToLines)
00082 {
00083 tf::Vector3 point;
00084 ASSERT_TRUE(swri_geometry_util::ClosestPointToLines(
00085 tf::Vector3(0, 0, 0),
00086 tf::Vector3(10, 0, 0),
00087 tf::Vector3(0, 0, 0),
00088 tf::Vector3(0, 10, 0),
00089 point));
00090 EXPECT_FLOAT_EQ(point.x(), 0);
00091 EXPECT_FLOAT_EQ(point.y(), 0);
00092 EXPECT_FLOAT_EQ(point.z(), 0);
00093
00094 ASSERT_TRUE(swri_geometry_util::ClosestPointToLines(
00095 tf::Vector3(0, 0, 0),
00096 tf::Vector3(10, 0, 0),
00097 tf::Vector3(0, 5, 0),
00098 tf::Vector3(0, 10, 0),
00099 point));
00100 EXPECT_FLOAT_EQ(point.x(), 0);
00101 EXPECT_FLOAT_EQ(point.y(), 0);
00102 EXPECT_FLOAT_EQ(point.z(), 0);
00103
00104 ASSERT_TRUE(swri_geometry_util::ClosestPointToLines(
00105 tf::Vector3(5, 0, 0),
00106 tf::Vector3(10, 0, 0),
00107 tf::Vector3(0, 5, 0),
00108 tf::Vector3(0, 10, 0),
00109 point));
00110 EXPECT_FLOAT_EQ(point.x(), 0);
00111 EXPECT_FLOAT_EQ(point.y(), 0);
00112 EXPECT_FLOAT_EQ(point.z(), 0);
00113
00114 ASSERT_TRUE(swri_geometry_util::ClosestPointToLines(
00115 tf::Vector3(0, 0, 0),
00116 tf::Vector3(10, 0, 0),
00117 tf::Vector3(0, -5, 0),
00118 tf::Vector3(0, 10, 0),
00119 point));
00120 EXPECT_FLOAT_EQ(point.x(), 0);
00121 EXPECT_FLOAT_EQ(point.y(), 0);
00122 EXPECT_FLOAT_EQ(point.z(), 0);
00123
00124 ASSERT_TRUE(swri_geometry_util::ClosestPointToLines(
00125 tf::Vector3(0, 0, 0),
00126 tf::Vector3(10, 0, 0),
00127 tf::Vector3(0, 0, 20),
00128 tf::Vector3(0, 10, 20),
00129 point));
00130 EXPECT_FLOAT_EQ(point.x(), 0);
00131 EXPECT_FLOAT_EQ(point.y(), 0);
00132 EXPECT_FLOAT_EQ(point.z(), 10);
00133
00134 ASSERT_TRUE(swri_geometry_util::ClosestPointToLines(
00135 tf::Vector3(0, 0, 0),
00136 tf::Vector3(10, 0, 0),
00137 tf::Vector3(0, 10, 20),
00138 tf::Vector3(0, 0, 20),
00139 point));
00140 EXPECT_FLOAT_EQ(point.x(), 0);
00141 EXPECT_FLOAT_EQ(point.y(), 0);
00142 EXPECT_FLOAT_EQ(point.z(), 10);
00143 }
00144
00145
00146 int main(int argc, char **argv)
00147 {
00148 testing::InitGoogleTest(&argc, argv);
00149
00150 return RUN_ALL_TESTS();
00151 }