orient3d.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include <test_common.h>
  2. #include <igl/predicates/orient2d.h>
  3. #include <igl/predicates/orient3d.h>
  4. #include <igl/predicates/incircle.h>
  5. #include <igl/predicates/insphere.h>
  6. #include <igl/predicates/exactinit.h>
  7. #include <limits>
  8. // Didn't have the stamina to break the tests into separate files but they
  9. // should be
  10. TEST_CASE("orient3d", "[igl][predicates]")
  11. {
  12. using namespace igl::predicates;
  13. {
  14. Eigen::MatrixXd A(3,3);
  15. Eigen::MatrixXd B(3,3);
  16. Eigen::MatrixXd C(3,3);
  17. Eigen::MatrixXd D(3,3);
  18. A<<
  19. 0.0, 0.0, 0.0,
  20. 0.0, 0.0, 0.0,
  21. 0.0, 0.0, 0.0;
  22. B<<
  23. 1.0, 0.0, 0.0,
  24. 1.0, 0.0, 0.0,
  25. 1.0, 0.0, 0.0;
  26. C<<
  27. 0.0, 1.0, 0.0,
  28. 0.0, 1.0, 0.0,
  29. 0.0, 1.0, 0.0;
  30. D<<
  31. 0.0, 0.0, 1.0,
  32. 0.0, 0.0, -1.0,
  33. 0.0, 0.0, 0.0;
  34. Eigen::VectorXi R;
  35. igl::predicates::orient3d(A,B,C,D,R);
  36. REQUIRE(R.size() == 3);
  37. REQUIRE(R(0) == int(igl::predicates::Orientation::NEGATIVE));
  38. REQUIRE(R(1) == int(igl::predicates::Orientation::POSITIVE));
  39. REQUIRE(R(2) == int(igl::predicates::Orientation::COPLANAR));
  40. }
  41. {
  42. Eigen::MatrixXd A(1,3);
  43. Eigen::MatrixXd B(1,3);
  44. Eigen::MatrixXd C(1,3);
  45. Eigen::MatrixXd D(3,3);
  46. A<<
  47. 0.0, 0.0, 0.0,
  48. B<<
  49. 1.0, 0.0, 0.0,
  50. C<<
  51. 0.0, 1.0, 0.0,
  52. D<<
  53. 0.0, 0.0, 1.0,
  54. 0.0, 0.0, -1.0,
  55. 0.0, 0.0, 0.0;
  56. Eigen::VectorXi R;
  57. igl::predicates::orient3d(A,B,C,D,R);
  58. REQUIRE(R.size() == 3);
  59. REQUIRE(R(0) == int(igl::predicates::Orientation::NEGATIVE));
  60. REQUIRE(R(1) == int(igl::predicates::Orientation::POSITIVE));
  61. REQUIRE(R(2) == int(igl::predicates::Orientation::COPLANAR));
  62. }
  63. }