ContAlignedBox.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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/AlignedBox.h>
  9. namespace WwiseGTE
  10. {
  11. // Compute the minimum size aligned bounding box of the points. The
  12. // extreme values are the minima and maxima of the point coordinates.
  13. template <int N, typename Real>
  14. bool GetContainer(int numPoints, Vector<N, Real> const* points, AlignedBox<N, Real>& box)
  15. {
  16. return ComputeExtremes(numPoints, points, box.min, box.max);
  17. }
  18. // Test for containment.
  19. template <int N, typename Real>
  20. bool InContainer(Vector<N, Real> const& point, AlignedBox<N, Real> const& box)
  21. {
  22. for (int i = 0; i < N; ++i)
  23. {
  24. Real value = point[i];
  25. if (value < box.min[i] || value > box.max[i])
  26. {
  27. return false;
  28. }
  29. }
  30. return true;
  31. }
  32. // Construct an aligned box that contains two other aligned boxes. The
  33. // result is the minimum size box containing the input boxes.
  34. template <int N, typename Real>
  35. bool MergeContainers(AlignedBox<N, Real> const& box0,
  36. AlignedBox<N, Real> const& box1, AlignedBox<N, Real>& merge)
  37. {
  38. for (int i = 0; i < N; ++i)
  39. {
  40. merge.min[i] = std::min(box0.min[i], box1.min[i]);
  41. merge.max[i] = std::max(box0.max[i], box1.max[i]);
  42. }
  43. return true;
  44. }
  45. }