sort_angles.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
  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. // Inputs:
  18. // M: m by n matrix of scalars. (n >= 2). Assuming the first column of M
  19. // contains values for y, and the second column is x. Using the rest
  20. // of the columns as tie-breaker.
  21. // R: an array of m indices. M.row(R[i]) contains the i-th smallest
  22. // angle.
  23. template<typename DerivedM, typename DerivedR>
  24. IGL_INLINE void sort_angles(
  25. const Eigen::PlainObjectBase<DerivedM>& M,
  26. Eigen::PlainObjectBase<DerivedR>& R);
  27. }
  28. #ifndef IGL_STATIC_LIBRARY
  29. #include "sort_angles.cpp"
  30. #endif
  31. #endif