unproject_on_plane.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  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. typedef typename DerivedZ::Scalar Scalar;
  18. Eigen::Matrix<Scalar,2,3> A;
  19. Eigen::Matrix<Scalar,2,1> B;
  20. projection_constraint(UV,M,VP,A,B);
  21. Eigen::Matrix<Scalar,3,3> AA;
  22. AA.topRows(2) = A.template cast<Scalar>();
  23. AA.row(2) = P.head(3).template cast<Scalar>();
  24. Eigen::Matrix<Scalar,3,1> BB;
  25. BB.head(2) = B.template cast<Scalar>();
  26. BB(2) = -P(3);
  27. Z = AA.fullPivHouseholderQr().solve(BB);
  28. }
  29. #ifdef IGL_STATIC_LIBRARY
  30. // Explicit template instantiation
  31. // generated by autoexplicit.sh
  32. template void igl::unproject_on_plane<Eigen::Matrix<double, 2, 1, 0, 2, 1>, Eigen::Matrix<float, 4, 4, 0, 4, 4>, Eigen::Matrix<float, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 1, 4, 1, 1, 4>, Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 2, 1, 0, 2, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<float, 4, 4, 0, 4, 4> > const&, Eigen::MatrixBase<Eigen::Matrix<float, 4, 1, 0, 4, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, 1, 4, 1, 1, 4> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&);
  33. #endif