unproject_to_zero_plane.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #ifndef IGL_NO_OPENGL
  10. #include "OpenGL_convenience.h"
  11. #include "project.h"
  12. #include "unproject.h"
  13. IGL_INLINE void igl::unproject_to_zero_plane(
  14. const double winX,
  15. const double winY,
  16. double* objX,
  17. double* objY,
  18. double* objZ)
  19. {
  20. double winOrigin[3];
  21. igl::project(0,0,0,&winOrigin[0],&winOrigin[1],&winOrigin[2]);
  22. return igl::unproject(winX, winY, winOrigin[2], objX, objY, objZ);
  23. }
  24. template <typename Derivedwin, typename Derivedobj>
  25. IGL_INLINE void igl::unproject_to_zero_plane(
  26. const Eigen::PlainObjectBase<Derivedwin> & win,
  27. Eigen::PlainObjectBase<Derivedobj> & obj)
  28. {
  29. return unproject_to_zero_plane(win(0),win(1),
  30. &obj.data()[0],
  31. &obj.data()[1],
  32. &obj.data()[2]);
  33. }
  34. #ifdef IGL_STATIC_LIBRARY
  35. // Explicit template instanciation
  36. template void 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> >&);
  37. template void igl::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::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
  40. #endif