project.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #ifndef IGL_PROJECT_H
  9. #define IGL_PROJECT_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Dense>
  12. namespace igl
  13. {
  14. // Wrapper for gluProject that uses the current GL_MODELVIEW_MATRIX,
  15. // GL_PROJECTION_MATRIX, and GL_VIEWPORT
  16. // Inputs:
  17. // obj* 3D objects' x, y, and z coordinates respectively
  18. // Outputs:
  19. // win* pointers to screen space x, y, and z coordinates respectively
  20. // Returns return value of gluProject call
  21. IGL_INLINE int project(
  22. const double objX,
  23. const double objY,
  24. const double objZ,
  25. double* winX,
  26. double* winY,
  27. double* winZ);
  28. // Eigen wrapper
  29. template <typename Derivedobj, typename Derivedwin>
  30. IGL_INLINE int project(
  31. const Eigen::PlainObjectBase<Derivedobj> & obj,
  32. Eigen::PlainObjectBase<Derivedwin> & win);
  33. // Eigen wrapper with return
  34. template <typename Derivedobj>
  35. IGL_INLINE Eigen::PlainObjectBase<Derivedobj> project(
  36. const Eigen::PlainObjectBase<Derivedobj> & obj);
  37. }
  38. #ifdef IGL_HEADER_ONLY
  39. # include "project.cpp"
  40. #endif
  41. #endif