IntrPlane3OrientedBox3.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // David Eberly, Geometric Tools, Redmond WA 98052
  2. // Copyright (c) 1998-2020
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // https://www.boost.org/LICENSE_1_0.txt
  5. // https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
  6. // Version: 4.0.2019.08.13
  7. #pragma once
  8. #include <Mathematics/TIQuery.h>
  9. #include <Mathematics/DistPoint3Plane3.h>
  10. #include <Mathematics/OrientedBox.h>
  11. namespace WwiseGTE
  12. {
  13. template <typename Real>
  14. class TIQuery<Real, Plane3<Real>, OrientedBox3<Real>>
  15. {
  16. public:
  17. struct Result
  18. {
  19. bool intersect;
  20. };
  21. Result operator()(Plane3<Real> const& plane, OrientedBox3<Real> const& box)
  22. {
  23. Result result;
  24. Real radius =
  25. std::fabs(box.extent[0] * Dot(plane.normal, box.axis[0])) +
  26. std::fabs(box.extent[1] * Dot(plane.normal, box.axis[1])) +
  27. std::fabs(box.extent[2] * Dot(plane.normal, box.axis[2]));
  28. DCPQuery<Real, Vector3<Real>, Plane3<Real>> ppQuery;
  29. auto ppResult = ppQuery(box.center, plane);
  30. result.intersect = (ppResult.distance <= radius);
  31. return result;
  32. }
  33. };
  34. }