Giter VIP home page Giter VIP logo

pointin3dpolygon's Introduction

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 <vector> and <algorithm>.

Compatibility and Dependencies

  • C++ 11 Standard and above
  • Standard Template Library (STL)

PointInPolygon 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

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 <iostream>
#include "PointInPolygon.h"

using namespace pip;

int main()
{
	std::vector<Point> 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;
}

pointin3dpolygon's People

Contributors

stefanjohnsen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.