oriented_bounding_box.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2025 Alec Jacobson <[email protected]>
  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_ORIENTED_BOUNDING_BOX_H
  9. #define IGL_ORIENTED_BOUNDING_BOX_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <Eigen/Geometry>
  13. #include <vector>
  14. namespace igl
  15. {
  16. enum OrientedBoundingBoxMinimizeType
  17. {
  18. ORIENTED_BOUNDING_BOX_MINIMIZE_VOLUME = 0,
  19. ORIENTED_BOUNDING_BOX_MINIMIZE_SURFACE_AREA = 1,
  20. ORIENTED_BOUNDING_BOX_MINIMIZE_DIAGONAL_LENGTH = 2,
  21. NUM_ORIENTED_BOUNDING_BOX_MINIMIZE_TYPES = 3,
  22. };
  23. /// Given a set of points compute the rotation transformation of them such
  24. /// that their axis-aligned bounding box is as small as possible.
  25. ///
  26. /// Consider passing the points on the convex hull of original list of points.
  27. ///
  28. /// @param[in] P #P by 3 list of point locations
  29. /// @param[in] n number of rotations to try
  30. /// @param[in] minimize_type which quantity to minimize
  31. /// @param[out] R rotation matrix
  32. template <typename DerivedP, typename DerivedR>
  33. IGL_INLINE void oriented_bounding_box(
  34. const Eigen::MatrixBase<DerivedP>& P,
  35. const int n,
  36. const OrientedBoundingBoxMinimizeType minimize_type,
  37. Eigen::PlainObjectBase<DerivedR> & R);
  38. }
  39. #ifndef IGL_STATIC_LIBRARY
  40. #include "oriented_bounding_box.cpp"
  41. #endif
  42. #endif