sort_angles.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 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 SORT_ANGLES_H
  9. #define SORT_ANGLES_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl {
  13. /// Sort angles in ascending order in a numerically robust way.
  14. ///
  15. /// Instead of computing angles using atan2(y, x), sort directly on (y, x).
  16. ///
  17. /// @param[in] M: m by n matrix of scalars. (n >= 2). Assuming the first
  18. /// column of M contains values for y, and the second column is x. Using
  19. /// the rest of the columns as tie-breaker.
  20. /// @param[in] R: an array of m indices. M.row(R[i]) contains the i-th
  21. /// smallest angle.
  22. template<typename DerivedM, typename DerivedR>
  23. IGL_INLINE void sort_angles(
  24. const Eigen::MatrixBase<DerivedM>& M,
  25. Eigen::PlainObjectBase<DerivedR>& R);
  26. }
  27. #ifndef IGL_STATIC_LIBRARY
  28. #include "sort_angles.cpp"
  29. #endif
  30. #endif