projection_constraint.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef IGL_PROJECTION_CONSTRAINT_H
  2. #define IGL_PROJECTION_CONSTRAINT_H
  3. #include <Eigen/Core>
  4. namespace igl
  5. {
  6. /// Construct two constraint equations for projecting a point to the screen. Of the form:
  7. ///
  8. /// A z = B
  9. ///
  10. /// with A 2x3 and B 2x1, where z is the 3d position of point in the scene,
  11. /// given the current projection matrix (e.g. gl_proj * gl_modelview), viewport
  12. /// (corner u/v and width/height) and screen space point x,y. Satisfying this
  13. /// equation means that z projects to screen space point (x,y).
  14. ///
  15. /// @param[in] UV 2-long uv-coordinates of screen space point
  16. /// @param[in] M 4 by 4 projection matrix
  17. /// @param[in] VP 4-long viewport: (corner_u, corner_v, width, height)
  18. /// @param[out] A 2 by 3 system matrix
  19. /// @param[out] B 2 by 1 right-hand side
  20. template <
  21. typename DerivedUV,
  22. typename DerivedM,
  23. typename DerivedVP,
  24. typename DerivedA,
  25. typename DerivedB>
  26. void projection_constraint(
  27. const Eigen::MatrixBase<DerivedUV> & UV,
  28. const Eigen::MatrixBase<DerivedM> & M,
  29. const Eigen::MatrixBase<DerivedVP> & VP,
  30. Eigen::PlainObjectBase<DerivedA> & A,
  31. Eigen::PlainObjectBase<DerivedB> & B);
  32. }
  33. #ifndef IGL_STATIC_LIBRARY
  34. # include "projection_constraint.cpp"
  35. #endif
  36. #endif