ray_triangle_intersect.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef IGL_RAY_TRIANGLE_INTERSECT_H
  2. #define IGL_RAY_TRIANGLE_INTERSECT_H
  3. #include "igl_inline.h"
  4. #include <Eigen/Core>
  5. namespace igl
  6. {
  7. /// Determine whether (and if so where) a ray intersects a triangle at a
  8. /// single point.
  9. ///
  10. /// @param[in] O 3d origin of ray
  11. /// @param[in] D 3d direction of ray
  12. /// @param[in] V0 3d position of first triangle vertex
  13. /// @param[in] V1 3d position of second triangle vertex
  14. /// @param[in] V2 3d position of third triangle vertex
  15. /// @param[in] epsilon epsilon for determining whether ray is parallel to
  16. /// triangle
  17. /// @param[out] t distance along ray to intersection (if any)
  18. /// @param[out] u barycentric coordinate of V1 triangle vertex
  19. /// @param[out] v barycentric coordinate of V2 triangle vertex
  20. /// @param[out] parallel whether ray was considered parallel to triangle (and
  21. /// if so then will return false)
  22. /// @returns true if ray intersects triangle
  23. ///
  24. ///
  25. template <
  26. typename DerivedO,
  27. typename DerivedD,
  28. typename DerivedV0,
  29. typename DerivedV1,
  30. typename DerivedV2>
  31. IGL_INLINE bool ray_triangle_intersect(
  32. const Eigen::MatrixBase<DerivedO> & O,
  33. const Eigen::MatrixBase<DerivedD> & D,
  34. const Eigen::MatrixBase<DerivedV0> & V0,
  35. const Eigen::MatrixBase<DerivedV1> & V1,
  36. const Eigen::MatrixBase<DerivedV2> & V2,
  37. const typename DerivedO::Scalar epsilon,
  38. typename DerivedO::Scalar & t,
  39. typename DerivedO::Scalar & u,
  40. typename DerivedO::Scalar & v,
  41. bool & parallel);
  42. }
  43. #ifndef IGL_STATIC_LIBRARY
  44. # include "ray_triangle_intersect.cpp"
  45. #endif
  46. #endif