sort_vectors_ccw.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. // do_sorted boolean flag, determines whether to return the sorted vector set
  21. // do_inv_order boolean flag, determines whether to return the "inverse" set of indices
  22. // Output:
  23. // order N by 1 order of the vectors (indices of the unordered vectors into
  24. // the ordered vector set)
  25. // sorted 1 by 3N row vector of the ordered vectors, stacked horizontally
  26. // inv_order N by 1 "inverse" order of the vectors (the indices of the ordered
  27. // vectors into the unordered vector set)
  28. //
  29. template <typename DerivedS, typename DerivedI>
  30. IGL_INLINE void sort_vectors_ccw(
  31. const Eigen::PlainObjectBase<DerivedS>& P,
  32. const Eigen::PlainObjectBase<DerivedS>& N,
  33. Eigen::PlainObjectBase<DerivedI> &order,
  34. const bool do_sorted,
  35. Eigen::PlainObjectBase<DerivedS> &sorted,
  36. const bool do_inv_order,
  37. Eigen::PlainObjectBase<DerivedI> &inv_order);
  38. };
  39. #ifndef IGL_STATIC_LIBRARY
  40. #include "sort_vectors_ccw.cpp"
  41. #endif
  42. #endif /* defined(IGL_FIELD_LOCAL_GLOBAL_CONVERSIONS) */