DistPoint3Plane3.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  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/DCPQuery.h>
  9. #include <Mathematics/Hyperplane.h>
  10. #include <Mathematics/Vector3.h>
  11. namespace WwiseGTE
  12. {
  13. template <typename Real>
  14. class DCPQuery<Real, Vector3<Real>, Plane3<Real>>
  15. {
  16. public:
  17. struct Result
  18. {
  19. Real distance, signedDistance;
  20. Vector3<Real> planeClosestPoint;
  21. };
  22. Result operator()(Vector3<Real> const& point, Plane3<Real> const& plane)
  23. {
  24. Result result;
  25. result.signedDistance = Dot(plane.normal, point) - plane.constant;
  26. result.distance = std::fabs(result.signedDistance);
  27. result.planeClosestPoint = point - result.signedDistance * plane.normal;
  28. return result;
  29. }
  30. };
  31. }