rigid_alignment.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2019 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/rigid_alignment.h>
  10. #include <igl/matlab_format.h>
  11. #include <iostream>
  12. TEST_CASE("rigid_alignment: identity", "[igl]")
  13. {
  14. const Eigen::MatrixXd X = (Eigen::MatrixXd(10,3)<<
  15. 0.814724,0.157613,0.655741,
  16. 0.905792,0.970593,0.035712,
  17. 0.126987,0.957167,0.849129,
  18. 0.913376,0.485376,0.933993,
  19. 0.632359,0.800280,0.678735,
  20. 0.097540,0.141886,0.757740,
  21. 0.278498,0.421761,0.743132,
  22. 0.546882,0.915736,0.392227,
  23. 0.957507,0.792207,0.655478,
  24. 0.964889,0.959492,0.171187).finished();
  25. const Eigen::MatrixXd Y = X;
  26. const Eigen::MatrixXd N = (Y.array()-0.5).matrix().rowwise().normalized();
  27. Eigen::Matrix3d R;
  28. Eigen::RowVector3d t;
  29. igl::rigid_alignment(X,Y,N,R,t);
  30. test_common::assert_near(R,Eigen::Matrix3d::Identity(),1e-12);
  31. test_common::assert_near(t,Eigen::RowVector3d::Zero(),1e-12);
  32. }