sort_angles.h 818 B

123456789101112131415161718192021222324252627
  1. #ifndef SORT_ANGLES_H
  2. #define SORT_ANGLES_H
  3. #include "igl_inline.h"
  4. namespace igl {
  5. // Sort angles in ascending order in a numerically robust way.
  6. //
  7. // Instead of computing angles using atan2(y, x), sort directly on (y, x).
  8. //
  9. // Inputs:
  10. // M: m by n matrix of scalars. (n >= 2). Assuming the first column of M
  11. // contains values for y, and the second column is x. Using the rest
  12. // of the columns as tie-breaker.
  13. // R: an array of m indices. M.row(R[i]) contains the i-th smallest
  14. // angle.
  15. template<typename DerivedM, typename DerivedR>
  16. IGL_INLINE void sort_angles(
  17. const Eigen::PlainObjectBase<DerivedM>& M,
  18. Eigen::PlainObjectBase<DerivedR>& R);
  19. }
  20. #ifndef IGL_STATIC_LIBRARY
  21. #include "sort_angles.cpp"
  22. #endif
  23. #endif