Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stefanjohnsen/pointin3dpolygon
Verify whether a 3D point lies within an planar non-complex polygon in three-dimensional space.
https://github.com/stefanjohnsen/pointin3dpolygon
3d-graphics pip polygon
Last synced: about 1 month ago
JSON representation
Verify whether a 3D point lies within an planar non-complex polygon in three-dimensional space.
- Host: GitHub
- URL: https://github.com/stefanjohnsen/pointin3dpolygon
- Owner: StefanJohnsen
- License: mit
- Created: 2024-03-09T22:44:06.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-03-17T15:18:25.000Z (10 months ago)
- Last Synced: 2024-03-17T16:29:36.261Z (10 months ago)
- Topics: 3d-graphics, pip, polygon
- Language: C++
- Homepage:
- Size: 48.2 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Point in 3D polygon
A header-only file providing a template-based solution for determining if a point resides within a three-dimensional non-complex polygon. This solution is self-contained and does not rely on external libraries, with the only dependency being the inclusion of `` and ``.### Compatibility and Dependencies
- C++ 11 Standard and above
- Standard Template Library (STL)![PointInPolygon](https://github.com/StefanJohnsen/PointInPolygon/blob/main/pictures/pic-01.png)
*The stress test results for the PointInPolygon function applied to a 3D planar polygon with 180.000 test points. More test results can be found [here](Polygons-obj/README.md)*### Supported polygons
The solution works for all kinds of 3D non-complex polygons, concave or convex, open or closed.### OS Support
- Windows
- Linux
- macOS### Usage
Copy `PointInPolygon.h` to your project and include the file.```
#include
#include "PointInPolygon.h"using namespace pip;
int main()
{
std::vector polygon;polygon.emplace_back(0.0f, 0.0f, 0.0f);
polygon.emplace_back(2.0f, 0.0f, 0.0f);
polygon.emplace_back(2.0f, 2.0f, 0.0f);
polygon.emplace_back(0.0f, 2.0f, 0.0f);const Point p = {1.0f , 1.0f , 0.0f};
if( pip::pointInPolygon(polygon, p) )
std::cout << "Point inside polygon!\n";
else
std::cout << "Point outside polygon!\n";return 0;
}
```