IntrPlane3Ellipsoid3.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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/Hyperellipsoid.h>
  11. #include <Mathematics/Matrix3x3.h>
  12. namespace WwiseGTE
  13. {
  14. template <typename Real>
  15. class TIQuery<Real, Plane3<Real>, Ellipsoid3<Real>>
  16. {
  17. public:
  18. struct Result
  19. {
  20. bool intersect;
  21. };
  22. Result operator()(Plane3<Real> const& plane, Ellipsoid3<Real> const& ellipsoid)
  23. {
  24. Result result;
  25. Matrix3x3<Real> MInverse;
  26. ellipsoid.GetMInverse(MInverse);
  27. Real discr = Dot(plane.normal, MInverse * plane.normal);
  28. Real root = std::sqrt(std::max(discr, (Real)0));
  29. DCPQuery<Real, Vector3<Real>, Plane3<Real>> vpQuery;
  30. Real distance = vpQuery(ellipsoid.center, plane).distance;
  31. result.intersect = (distance <= root);
  32. return result;
  33. }
  34. };
  35. }