sort_vectors_ccw.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Olga Diamanti <olga.diam@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 IGL_SORT_VECTORS_CCW
  9. #define IGL_SORT_VECTORS_CCW
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl {
  13. // Sorts a set of N coplanar vectors in a ccw order, and returns their order.
  14. // Optionally it also returns a copy of the ordered vector set, or the indices,
  15. // in the original unordered set, of the vectors in the ordered set (called here
  16. // the "inverse" set of indices).
  17. // Inputs:
  18. // P 1 by 3N row vector of the vectors to be sorted, stacked horizontally
  19. // N #1 by 3 normal of the plane where the vectors lie
  20. // Output:
  21. // order N by 1 order of the vectors (indices of the unordered vectors into
  22. // the ordered vector set)
  23. // sorted 1 by 3N row vector of the ordered vectors, stacked horizontally
  24. // inv_order N by 1 "inverse" order of the vectors (the indices of the ordered
  25. // vectors into the unordered vector set)
  26. //
  27. template <typename DerivedS, typename DerivedI>
  28. IGL_INLINE void sort_vectors_ccw(
  29. const Eigen::PlainObjectBase<DerivedS>& P,
  30. const Eigen::PlainObjectBase<DerivedS>& N,
  31. Eigen::PlainObjectBase<DerivedI> &order,
  32. Eigen::PlainObjectBase<DerivedS> &sorted,
  33. Eigen::PlainObjectBase<DerivedI> &inv_order);
  34. template <typename DerivedS, typename DerivedI>
  35. IGL_INLINE void sort_vectors_ccw(
  36. const Eigen::PlainObjectBase<DerivedS>& P,
  37. const Eigen::PlainObjectBase<DerivedS>& N,
  38. Eigen::PlainObjectBase<DerivedI> &order,
  39. Eigen::PlainObjectBase<DerivedS> &sorted);
  40. template <typename DerivedS, typename DerivedI>
  41. IGL_INLINE void sort_vectors_ccw(
  42. const Eigen::PlainObjectBase<DerivedS>& P,
  43. const Eigen::PlainObjectBase<DerivedS>& N,
  44. Eigen::PlainObjectBase<DerivedI> &order,
  45. Eigen::PlainObjectBase<DerivedI> &inv_order);
  46. template <typename DerivedS, typename DerivedI>
  47. IGL_INLINE void sort_vectors_ccw(
  48. const Eigen::PlainObjectBase<DerivedS>& P,
  49. const Eigen::PlainObjectBase<DerivedS>& N,
  50. Eigen::PlainObjectBase<DerivedI> &order);
  51. };
  52. #ifndef IGL_STATIC_LIBRARY
  53. #include "sort_vectors_ccw.cpp"
  54. #endif
  55. #endif /* defined(IGL_FIELD_LOCAL_GLOBAL_CONVERSIONS) */