project.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. // Eigen reimplementation of gluProject
  15. // Inputs:
  16. // obj* 3D objects' x, y, and z coordinates respectively
  17. // model model matrix
  18. // proj projection matrix
  19. // viewport viewport vector
  20. // Returns:
  21. // screen space x, y, and z coordinates respectively
  22. template <typename Scalar>
  23. IGL_INLINE Eigen::Matrix<Scalar,3,1> project(
  24. const Eigen::Matrix<Scalar,3,1>& obj,
  25. const Eigen::Matrix<Scalar,4,4>& model,
  26. const Eigen::Matrix<Scalar,4,4>& proj,
  27. const Eigen::Matrix<Scalar,4,1>& viewport);
  28. // Inputs:
  29. // V #V by 3 list of object points
  30. // model model matrix
  31. // proj projection matrix
  32. // viewport viewport vector
  33. // Outputs:
  34. // P #V by 3 list of screen space points
  35. template <typename DerivedV, typename Scalar, typename DerivedP>
  36. IGL_INLINE void project(
  37. const Eigen::PlainObjectBase<DerivedV>& V,
  38. const Eigen::Matrix<Scalar,4,4>& model,
  39. const Eigen::Matrix<Scalar,4,4>& proj,
  40. const Eigen::Matrix<Scalar,4,1>& viewport,
  41. Eigen::PlainObjectBase<DerivedP> & P);
  42. }
  43. #ifndef IGL_STATIC_LIBRARY
  44. # include "project.cpp"
  45. #endif
  46. #endif