sort_angles.h 840 B

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