orient2d.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2019 Qingnan Zhou <[email protected]>
  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. #pragma once
  9. #ifndef IGL_PREDICATES_ORIENT2D_H
  10. #define IGL_PREDICATES_ORIENT2D_H
  11. #include "../igl_inline.h"
  12. #include <Eigen/Core>
  13. #include "Orientation.h"
  14. namespace igl {
  15. namespace predicates {
  16. /// Compute the orientation of the triangle formed by pa, pb, pc.
  17. ///
  18. /// @param[in] pa 2D point on line
  19. /// @param[in] pb 2D point on line
  20. /// @param[in] pc 2D query point.
  21. /// @return POSITIVE if pa, pb, pc are counterclockwise oriented.
  22. /// NEGATIVE if they are clockwise oriented.
  23. /// COLLINEAR if they are collinear.
  24. ///
  25. /// \fileinfo
  26. template<typename Vector2D>
  27. IGL_INLINE Orientation orient2d(
  28. const Eigen::MatrixBase<Vector2D>& pa,
  29. const Eigen::MatrixBase<Vector2D>& pb,
  30. const Eigen::MatrixBase<Vector2D>& pc);
  31. /// Compute the orientation of the tetrahedron formed by each 4-tuple of
  32. /// points
  33. ///
  34. /// @param[in] A #P|1 by 3 matrix of 3D points
  35. /// @param[in] B #P|1 by 3 matrix of 3D points
  36. /// @param[in] C #P|1 by 3 matrix of 3D points
  37. /// @param[out] R #P vector of orientations
  38. ///
  39. template
  40. <typename DerivedA,
  41. typename DerivedB,
  42. typename DerivedC,
  43. typename DerivedR>
  44. IGL_INLINE void orient2d(
  45. const Eigen::MatrixBase<DerivedA>& A,
  46. const Eigen::MatrixBase<DerivedB>& B,
  47. const Eigen::MatrixBase<DerivedC>& C,
  48. Eigen::PlainObjectBase<DerivedR>& R);
  49. }
  50. }
  51. #ifndef IGL_STATIC_LIBRARY
  52. #include "orient2d.cpp"
  53. #endif
  54. #endif