frustum.cpp 705 B

123456789101112131415161718192021
  1. #include "frustum.h"
  2. template < typename DerivedP>
  3. IGL_INLINE void igl::frustum(
  4. const typename DerivedP::Scalar left,
  5. const typename DerivedP::Scalar right,
  6. const typename DerivedP::Scalar bottom,
  7. const typename DerivedP::Scalar top,
  8. const typename DerivedP::Scalar nearVal,
  9. const typename DerivedP::Scalar farVal,
  10. Eigen::PlainObjectBase<DerivedP> & P)
  11. {
  12. P.setConstant(4,4,0.);
  13. P(0,0) = (2.0 * nearVal) / (right - left);
  14. P(1,1) = (2.0 * nearVal) / (top - bottom);
  15. P(0,2) = (right + left) / (right - left);
  16. P(1,2) = (top + bottom) / (top - bottom);
  17. P(2,2) = -(farVal + nearVal) / (farVal - nearVal);
  18. P(3,2) = -1.0;
  19. P(2,3) = -(2.0 * farVal * nearVal) / (farVal - nearVal);
  20. }