bezier.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2020 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/bezier.h>
  10. TEST_CASE("bezier: ease", "[igl]")
  11. {
  12. // Ease curve
  13. const Eigen::MatrixXd C =
  14. (Eigen::MatrixXd(4,2)<<0,0,0.5,0,0.5,1,1,1).finished();
  15. const Eigen::VectorXd T =
  16. (Eigen::VectorXd(11,1)<<0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1).finished();
  17. Eigen::MatrixXd P;
  18. igl::bezier(C,T,P);
  19. const Eigen::MatrixXd Pexact = (Eigen::MatrixXd(11,2)<<
  20. 0.00000000000000000,0.00000000000000000,
  21. 0.13600000000000001,0.02800000000000001,
  22. 0.24800000000000008,0.10400000000000004,
  23. 0.34199999999999997,0.21599999999999997,
  24. 0.42400000000000004,0.35200000000000004,
  25. 0.50000000000000000,0.50000000000000000,
  26. 0.57600000000000007,0.64800000000000002,
  27. 0.65799999999999992,0.78399999999999992,
  28. 0.75200000000000011,0.89600000000000013,
  29. 0.86400000000000010,0.97200000000000009,
  30. 1.00000000000000000,1.00000000000000000).finished();
  31. test_common::assert_near(P,Pexact,1e-15);
  32. }