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
00031
00032
00033
00034
00035
00036
00037
00038 #include <gtest/gtest.h>
00039 #include <pcl/common/common.h>
00040 #include <pcl/common/distances.h>
00041 #include <pcl/common/eigen.h>
00042 #include <pcl/point_types.h>
00043 #include <sys/time.h>
00044
00045 using pcl::PointXYZ;
00046
00047 TEST (PCL, Common)
00048 {
00049 PointXYZ p1, p2, p3;
00050 p1.x = 1; p1.y = p1.z = 0;
00051 p2.y = 1; p2.x = p2.z = 0;
00052 p3.z = 1; p3.x = p3.y = 0;
00053 double radius = getCircumcircleRadius (p1, p2, p3);
00054 EXPECT_NEAR (radius, 0.816497, 1e-4);
00055
00056 Eigen::Vector4f pt (1,0,0,0), line_pt (0,0,0,0), line_dir (1,1,0,0);
00057 double point2line_disance = sqrt (pcl::sqrPointToLineDistance (pt, line_pt, line_dir));
00058 EXPECT_NEAR (point2line_disance, sqrt(2)/2, 1e-4);
00059 }
00060
00061 TEST (PCL, Eigen)
00062 {
00063 Eigen::Matrix3f mat, vec;
00064 mat << 0.000536227, -1.56178e-05, -9.47391e-05, -1.56178e-05, 0.000297322, -0.000148785, -9.47391e-05, -0.000148785, 9.7827e-05;
00065 Eigen::Vector3f val;
00066
00067 pcl::eigen33 (mat, vec, val);
00068
00069 EXPECT_NEAR (fabs (vec (0, 0)), 0.168841, 1e-4); EXPECT_NEAR (fabs (vec (0, 1)), 0.161623, 1e-4); EXPECT_NEAR (fabs (vec (0, 2)), 0.972302, 1e-4);
00070 EXPECT_NEAR (fabs (vec (1, 0)), 0.451632, 1e-4); EXPECT_NEAR (fabs (vec (1, 1)), 0.889498, 1e-4); EXPECT_NEAR (fabs (vec (1, 2)), 0.0694328, 1e-4);
00071 EXPECT_NEAR (fabs (vec (2, 0)), 0.876082, 1e-4); EXPECT_NEAR (fabs (vec (2, 1)), 0.4274, 1e-4); EXPECT_NEAR (fabs (vec (2, 2)), 0.223178, 1e-4);
00072
00073 EXPECT_NEAR (val (0), 2.86806e-06, 1e-4); EXPECT_NEAR (val (1), 0.00037165, 1e-4); EXPECT_NEAR (val (2), 0.000556858, 1e-4);
00074
00075 Eigen::SelfAdjointEigenSolver<Eigen::Matrix3f> eig (mat);
00076
00077 EXPECT_NEAR (eig.eigenvectors () (0, 0), -0.168841, 1e-4); EXPECT_NEAR (eig.eigenvectors () (0, 1), 0.161623, 1e-4); EXPECT_NEAR (eig.eigenvectors () (0, 2), 0.972302, 1e-4);
00078 EXPECT_NEAR (eig.eigenvectors () (1, 0), -0.451632, 1e-4); EXPECT_NEAR (eig.eigenvectors () (1, 1), -0.889498, 1e-4); EXPECT_NEAR (eig.eigenvectors () (1, 2), 0.0694328, 1e-4);
00079 EXPECT_NEAR (eig.eigenvectors () (2, 0), -0.876083, 1e-4); EXPECT_NEAR (eig.eigenvectors () (2, 1), 0.4274, 1e-4); EXPECT_NEAR (eig.eigenvectors () (2, 2), -0.223178, 1e-4);
00080
00081 EXPECT_NEAR (eig.eigenvalues () (0), 2.86806e-06, 1e-4); EXPECT_NEAR (eig.eigenvalues () (1), 0.00037165, 1e-4); EXPECT_NEAR (eig.eigenvalues () (2), 0.000556858, 1e-4);
00082
00083 Eigen::Vector3f eivals = mat.selfadjointView<Eigen::Lower>().eigenvalues ();
00084
00085 EXPECT_NEAR (eivals (0), 2.86806e-06, 1e-4); EXPECT_NEAR (eivals (1), 0.00037165, 1e-4); EXPECT_NEAR (eivals (2), 0.000556858, 1e-4);
00086
00087 }
00088
00089
00090 int
00091 main (int argc, char** argv)
00092 {
00093 testing::InitGoogleTest (&argc, argv);
00094 return (RUN_ALL_TESTS ());
00095 }
00096