icosahedron.cpp 621 B

12345678910111213141516171819202122
  1. #include <test_common.h>
  2. #include <igl/icosahedron.h>
  3. #include <igl/doublearea.h>
  4. TEST_CASE("icosahedron: simple", "[igl]")
  5. {
  6. Eigen::MatrixXi F(2,3);
  7. F << 0,1,2,
  8. 1,2,3;
  9. Eigen::MatrixXd V;
  10. igl::icosahedron(V,F);
  11. REQUIRE(V.rows() == 12);
  12. REQUIRE(V.cols() == 3);
  13. REQUIRE(F.rows() == 20);
  14. REQUIRE(F.cols() == 3);
  15. REQUIRE(((V.rowwise().squaredNorm().array() - 1.0).abs()<1e-15).all());
  16. Eigen::VectorXd A;
  17. igl::doublearea(V,F,A);
  18. const auto std_dev = [](const Eigen::ArrayXd & vec){ return std::sqrt((vec - vec.mean()).square().sum()/(vec.size()-1));};
  19. REQUIRE(std_dev(A.array()) < 1e-15);
  20. }