unproject_ray.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson <[email protected]>
  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_UNPROJECT_RAY_H
  9. #define IGL_UNPROJECT_RAY_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. /// Construct a ray (source point + direction vector) given a screen space
  15. /// positions (e.g. mouse) and a model-view projection constellation.
  16. ///
  17. /// @param[in] pos 2d screen-space position (x,y)
  18. /// @param[in] model 4x4 model-view matrix
  19. /// @param[in] proj 4x4 projection matrix
  20. /// @param[in] viewport 4-long viewport vector
  21. /// @param[out] s source of ray (pos unprojected with z=0)
  22. /// @param[out] dir direction of ray (d - s) where d is pos unprojected with z=1
  23. ///
  24. template <
  25. typename Derivedpos,
  26. typename Derivedmodel,
  27. typename Derivedproj,
  28. typename Derivedviewport,
  29. typename Deriveds,
  30. typename Deriveddir>
  31. IGL_INLINE void unproject_ray(
  32. const Eigen::MatrixBase<Derivedpos> & pos,
  33. const Eigen::MatrixBase<Derivedmodel> & model,
  34. const Eigen::MatrixBase<Derivedproj> & proj,
  35. const Eigen::MatrixBase<Derivedviewport> & viewport,
  36. Eigen::PlainObjectBase<Deriveds> & s,
  37. Eigen::PlainObjectBase<Deriveddir> & dir);
  38. }
  39. #ifndef IGL_STATIC_LIBRARY
  40. # include "unproject_ray.cpp"
  41. #endif
  42. #endif