point_in_poly.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@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_POINT_IN_POLY_H
  9. #define IGL_POINT_IN_POLY_H
  10. #include "igl_inline.h"
  11. #include <vector>
  12. namespace igl
  13. {
  14. // Determine if 2d point is inside a 2D polygon
  15. // Inputs:
  16. // poly vector of polygon points, [0]=x, [1]=y.
  17. // Polyline need not be closed (i.e. first point != last point),
  18. // the line segment between last and first selected points is constructed
  19. // within this function.
  20. // x x-coordinate of query point
  21. // y y-coordinate of query point
  22. // Returns true if query point is in polygon, false otherwise
  23. // from http://www.visibone.com/inpoly/
  24. bool IGL_INLINE point_in_poly( const std::vector<std::vector<unsigned int > >&poly,
  25. const unsigned int xt,
  26. const unsigned int yt);
  27. }
  28. #ifndef IGL_STATIC_LIBRARY
  29. # include "point_in_poly.cpp"
  30. #endif
  31. #endif