8 #include <boost/test/unit_test.hpp>
9 #include <boost/utility/binary.hpp>
13 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
17 const int num_tests = int(1e5);
23 BOOST_CHECK(cone.
isInside(Eigen::Vector3d::Zero()));
24 BOOST_CHECK(cone.project(Eigen::Vector3d::Zero()) == Eigen::Vector3d::Zero());
26 BOOST_CHECK(dual_cone.
isInside(Eigen::Vector3d::Zero()));
27 BOOST_CHECK(dual_cone.project(Eigen::Vector3d::Zero()) == Eigen::Vector3d::Zero());
29 for (
int k = 0; k < num_tests; ++k)
31 const Eigen::Vector3d
x = Eigen::Vector3d::Random();
34 const Eigen::Vector3d proj_x = cone.project(
x);
35 const Eigen::Vector3d proj_proj_x = cone.project(proj_x);
37 BOOST_CHECK(cone.
isInside(proj_x, 1e-12));
38 BOOST_CHECK(cone.
isInside(proj_proj_x, 1e-12));
39 BOOST_CHECK(proj_x.isApprox(proj_proj_x));
41 BOOST_CHECK(
x == proj_x);
43 BOOST_CHECK(fabs((
x - proj_x).dot(proj_x)) <= 1e-12);
46 const Eigen::Vector3d dual_proj_x = dual_cone.project(
x);
47 const Eigen::Vector3d dual_proj_proj_x = dual_cone.project(dual_proj_x);
49 BOOST_CHECK(dual_cone.
isInside(dual_proj_x, 1e-12));
50 BOOST_CHECK(dual_cone.
isInside(dual_proj_proj_x, 1e-12));
51 BOOST_CHECK(dual_proj_x.isApprox(dual_proj_proj_x));
54 BOOST_CHECK(
x == dual_proj_x);
56 BOOST_CHECK(fabs((
x - dual_proj_x).dot(dual_proj_x)) <= 1e-12);
60 const Eigen::Vector3d radial_proj_x = cone.computeRadialProjection(
x);
61 const Eigen::Vector3d radial_proj_radial_proj_x = cone.computeRadialProjection(radial_proj_x);
62 BOOST_CHECK(cone.
isInside(radial_proj_x, 1e-12));
63 BOOST_CHECK(radial_proj_x[2] ==
x[2] || radial_proj_x[2] == 0.);
64 if (radial_proj_x[2] ==
x[2])
66 std::fabs(radial_proj_x.head<2>().normalized().dot(
x.head<2>().normalized()) - 1.)
69 BOOST_CHECK(radial_proj_x.head<2>().isZero());
70 BOOST_CHECK(radial_proj_radial_proj_x.isApprox(radial_proj_radial_proj_x));
75 BOOST_AUTO_TEST_SUITE_END()