unproject_on_plane.cpp 921 B

12345678910111213141516171819202122232425262728293031323334
  1. #include "unproject_on_plane.h"
  2. #include "projection_constraint.h"
  3. #include <Eigen/Dense>
  4. template <
  5. typename DerivedUV,
  6. typename DerivedM,
  7. typename DerivedVP,
  8. typename DerivedP,
  9. typename DerivedZ>
  10. void igl::unproject_on_plane(
  11. const Eigen::MatrixBase<DerivedUV> & UV,
  12. const Eigen::MatrixBase<DerivedM> & M,
  13. const Eigen::MatrixBase<DerivedVP> & VP,
  14. const Eigen::MatrixBase<DerivedP> & P,
  15. Eigen::PlainObjectBase<DerivedZ> & Z)
  16. {
  17. using namespace Eigen;
  18. typedef typename DerivedZ::Scalar Scalar;
  19. Matrix<Scalar,2,3> A;
  20. Matrix<Scalar,2,1> B;
  21. projection_constraint(UV,M,VP,A,B);
  22. Matrix<Scalar,3,3> AA;
  23. AA.topRows(2) = A.template cast<Scalar>();
  24. AA.row(2) = P.head(3).template cast<Scalar>();
  25. Matrix<Scalar,3,1> BB;
  26. BB.head(2) = B.template cast<Scalar>();
  27. BB(2) = -P(3);
  28. Z = AA.fullPivHouseholderQr().solve(BB);
  29. }
  30. #ifdef IGL_STATIC_LIBRARY
  31. // Explicit template instantiation
  32. #endif