unproject_on_plane.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef IGL_UNPROJECT_ON_PLANE_H
  2. #define IGL_UNPROJECT_ON_PLANE_H
  3. #include <Eigen/Core>
  4. namespace igl
  5. {
  6. /// Given a screen space point (u,v) and the current projection matrix (e.g.
  7. /// gl_proj * gl_modelview) and viewport, _unproject_ the point into the scene
  8. /// so that it lies on given plane.
  9. ///
  10. /// @param[in] UV 2-long uv-coordinates of screen space point
  11. /// @param[in] M 4 by 4 projection matrix
  12. /// @param[in] VP 4-long viewport: (corner_u, corner_v, width, height)
  13. /// @param[in] P 4-long plane equation coefficients: P*(X 1) = 0
  14. /// @param[out] Z 3-long world coordinate
  15. template <
  16. typename DerivedUV,
  17. typename DerivedM,
  18. typename DerivedVP,
  19. typename DerivedP,
  20. typename DerivedZ>
  21. void unproject_on_plane(
  22. const Eigen::MatrixBase<DerivedUV> & UV,
  23. const Eigen::MatrixBase<DerivedM> & M,
  24. const Eigen::MatrixBase<DerivedVP> & VP,
  25. const Eigen::MatrixBase<DerivedP> & P,
  26. Eigen::PlainObjectBase<DerivedZ> & Z);
  27. }
  28. #ifndef IGL_STATIC_LIBRARY
  29. # include "unproject_on_plane.cpp"
  30. #endif
  31. #endif