barycentric_interpolation.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2018 Alec Jacobson <[email protected]>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #include <test_common.h>
  9. #include <igl/barycentric_interpolation.h>
  10. TEST_CASE("barycentric_interpolation: two-triangles", "[igl]")
  11. {
  12. const Eigen::MatrixXd V =
  13. (Eigen::MatrixXd(4,3) <<
  14. 0,0,0,
  15. 1,0,0,
  16. 1,1,0,
  17. 0,1,0).finished();
  18. const Eigen::MatrixXi F =
  19. (Eigen::MatrixXi(2,3) << 0,1,2,0,2,3).finished();
  20. const Eigen::VectorXi I =
  21. (Eigen::VectorXi(4,1)<<0,0,1,1).finished();
  22. const Eigen::MatrixXd B =
  23. (Eigen::MatrixXd(4,3)<<
  24. 1,0,0,
  25. 0.5,0.5,0,
  26. 0.5,0.5,0,
  27. 0.25,0.25,0.5
  28. ).finished();
  29. const Eigen::MatrixXd Xgt =
  30. (Eigen::MatrixXd(4,3)<<
  31. 0,0,0,
  32. 0.5,0,0,
  33. 0.5,0.5,0,
  34. 0.25,0.75,0
  35. ).finished();
  36. Eigen::MatrixXd X;
  37. igl::barycentric_interpolation(V,F,B,I,X);
  38. test_common::assert_eq(X,Xgt);
  39. }