frustum.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 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. #include "frustum.h"
  9. template < typename DerivedP>
  10. IGL_INLINE void igl::frustum(
  11. const typename DerivedP::Scalar left,
  12. const typename DerivedP::Scalar right,
  13. const typename DerivedP::Scalar bottom,
  14. const typename DerivedP::Scalar top,
  15. const typename DerivedP::Scalar nearVal,
  16. const typename DerivedP::Scalar farVal,
  17. Eigen::PlainObjectBase<DerivedP> & P)
  18. {
  19. P.setConstant(4,4,0.);
  20. P(0,0) = (2.0 * nearVal) / (right - left);
  21. P(1,1) = (2.0 * nearVal) / (top - bottom);
  22. P(0,2) = (right + left) / (right - left);
  23. P(1,2) = (top + bottom) / (top - bottom);
  24. P(2,2) = -(farVal + nearVal) / (farVal - nearVal);
  25. P(3,2) = -1.0;
  26. P(2,3) = -(2.0 * farVal * nearVal) / (farVal - nearVal);
  27. }
  28. #ifdef IGL_STATIC_LIBRARY
  29. // Explicit template specialization
  30. // generated by autoexplicit.sh
  31. template void igl::frustum<Eigen::Matrix<float, 4, 4, 0, 4, 4> >(Eigen::Matrix<float, 4, 4, 0, 4, 4>::Scalar, Eigen::Matrix<float, 4, 4, 0, 4, 4>::Scalar, Eigen::Matrix<float, 4, 4, 0, 4, 4>::Scalar, Eigen::Matrix<float, 4, 4, 0, 4, 4>::Scalar, Eigen::Matrix<float, 4, 4, 0, 4, 4>::Scalar, Eigen::Matrix<float, 4, 4, 0, 4, 4>::Scalar, Eigen::PlainObjectBase<Eigen::Matrix<float, 4, 4, 0, 4, 4> >&);
  32. #endif