unproject_to_zero_plane.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  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 "unproject_to_zero_plane.h"
  9. #include "../opengl/OpenGL_convenience.h"
  10. #include "project.h"
  11. #include "unproject.h"
  12. IGL_INLINE void igl::opengl2::unproject_to_zero_plane(
  13. const double winX,
  14. const double winY,
  15. double* objX,
  16. double* objY,
  17. double* objZ)
  18. {
  19. double winOrigin[3];
  20. igl::opengl2::project(0,0,0,&winOrigin[0],&winOrigin[1],&winOrigin[2]);
  21. return igl::opengl2::unproject(winX, winY, winOrigin[2], objX, objY, objZ);
  22. }
  23. template <typename Derivedwin, typename Derivedobj>
  24. IGL_INLINE void igl::opengl2::unproject_to_zero_plane(
  25. const Eigen::PlainObjectBase<Derivedwin> & win,
  26. Eigen::PlainObjectBase<Derivedobj> & obj)
  27. {
  28. return unproject_to_zero_plane(win(0),win(1),
  29. &obj.data()[0],
  30. &obj.data()[1],
  31. &obj.data()[2]);
  32. }
  33. #ifdef IGL_STATIC_LIBRARY
  34. // Explicit template specialization
  35. // generated by autoexplicit.sh
  36. template void igl::opengl2::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> >&);
  37. template void igl::opengl2::unproject_to_zero_plane<Eigen::Matrix<double, 2, 1, 0, 2, 1>, Eigen::Matrix<double, 1, 3, 1, 1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 1, 0, 2, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&);
  38. template void igl::opengl2::unproject_to_zero_plane<Eigen::Matrix<double, 2, 1, 0, 2, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 1, 0, 2, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&);
  39. #endif