ray_box_intersect.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. #ifndef IGL_RAY_BOX_INTERSECT_H
  9. #define IGL_RAY_BOX_INTERSECT_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <Eigen/Geometry>
  13. namespace igl
  14. {
  15. // Determine whether a ray origin+t*dir and box intersect within the ray's parameterized
  16. // range (t0,t1)
  17. //
  18. // Inputs:
  19. // source 3-vector origin of ray
  20. // dir 3-vector direction of ray
  21. // box axis aligned box
  22. // t0 hit only if hit.t less than t0
  23. // t1 hit only if hit.t greater than t1
  24. // Returns true if hit
  25. template <
  26. typename Derivedsource,
  27. typename Deriveddir,
  28. typename Scalar>
  29. IGL_INLINE bool ray_box_intersect(
  30. const Eigen::PlainObjectBase<Derivedsource> & source,
  31. const Eigen::PlainObjectBase<Deriveddir> & dir,
  32. const Eigen::AlignedBox<Scalar,3> & box,
  33. const Scalar & t0,
  34. const Scalar & t1);
  35. }
  36. #ifndef IGL_STATIC_LIBRARY
  37. # include "ray_box_intersect.cpp"
  38. #endif
  39. #endif