MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / TEST

Function TEST

test/common/test_vector_average.cpp:44–70  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

42
43//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
44TEST (PCL, VectorAverage_mean)
45{
46 std::vector<Eigen::Vector3f, Eigen::aligned_allocator<Eigen::Vector3f> > points;
47 std::vector<Eigen::Vector3f::Scalar, Eigen::aligned_allocator<Eigen::Vector3f::Scalar> > weights;
48 points.emplace_back(-0.558191f, 0.180822f, -0.809769f);
49 weights.push_back (0.160842f);
50 points.emplace_back(-0.510641f, 0.290673f, -0.809169f);
51 weights.push_back (0.526732f);
52 points.emplace_back(-0.440713f, 0.385624f, -0.810597f);
53 weights.push_back (0.312427f);
54
55 Eigen::Vector3f correct_mean (0.0f, 0.0f, 0.0f);
56 float weigth_sum = 0.0f;
57 for (std::size_t i = 0; i < points.size (); ++i)
58 {
59 correct_mean += weights[i]*points[i];
60 weigth_sum += weights[i];
61 }
62 correct_mean /= weigth_sum;
63
64 pcl::VectorAverage<float, 3> va;
65 for (std::size_t i = 0; i < points.size(); ++i)
66 va.add(points[i], weights[i]);
67 Eigen::Vector3f mean = va.getMean();
68 //std::cout << "Correct: "<<correct_mean <<"\n"<< "Result: "<<mean<<"\n";
69 EXPECT_NEAR ((mean-correct_mean).norm(), 0.0f, 1e-4);
70}
71
72/* ---[ */
73int

Callers

nothing calls this directly

Calls 5

emplace_backMethod · 0.80
getMeanMethod · 0.80
push_backMethod · 0.45
sizeMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected