unproject_to_zero_plane.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "unproject_to_zero_plane.h"
  2. #ifndef IGL_NO_OPENGL
  3. #include "OpenGL_convenience.h"
  4. #include "project.h"
  5. #include "unproject.h"
  6. IGL_INLINE int igl::unproject_to_zero_plane(
  7. const double winX,
  8. const double winY,
  9. double* objX,
  10. double* objY,
  11. double* objZ)
  12. {
  13. double winOrigin[3];
  14. igl::project(0,0,0,&winOrigin[0],&winOrigin[1],&winOrigin[2]);
  15. return igl::unproject(winX, winY, winOrigin[2], objX, objY, objZ);
  16. }
  17. template <typename Derivedwin, typename Derivedobj>
  18. IGL_INLINE int igl::unproject_to_zero_plane(
  19. const Eigen::PlainObjectBase<Derivedwin> & win,
  20. Eigen::PlainObjectBase<Derivedobj> & obj)
  21. {
  22. return unproject_to_zero_plane(win(0),win(1),
  23. &obj.data()[0],
  24. &obj.data()[1],
  25. &obj.data()[2]);
  26. }
  27. #ifndef IGL_HEADER_ONLY
  28. // Explicit template instanciation
  29. template int igl::unproject_to_zero_plane<Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&);
  30. #endif
  31. #endif