Coder Social home page Coder Social logo

gtzinos / robust-point-in-polygon Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mikolalysenko/robust-point-in-polygon

3.0 1.0 0.0 5 KB

Exactly test if a point is inside, outside or on the boundary of a polygon

License: MIT License

JavaScript 100.00%

robust-point-in-polygon's Introduction

robust-point-in-polygon

Exactly determines if a point is contained in a 2D polygon.

Example

var classifyPoint = require("robust-point-in-polygon")
var polygon = [ [ 1, 1 ], [ 1, 2 ], [ 2, 2 ], [ 2, 1 ] ]

console.log(
  classifyPoint(polygon, [1.5, 1.5]),
  classifyPoint(polygon, [1, 2]),
  classifyPoint(polygom, [100000, 10000]))

Output:

-1 0 1

Install

npm install robust-point-in-polygon

API

require("robust-point-in-polygon")(loop, point)

Tests if a point is contained in the interior of a simple polygon

  • loop is an array of vertices for the polygon
  • point is a 2D point which is classified against the polygon

Returns An integer which determines the position of point relative to polygon. This has the following interpretation:

  • -1 if point is contained inside loop
  • 0 if point is on the boundary of loop
  • 1 if point is outside loop

Credits

(c) 2014 Mikola Lysenko. MIT License

robust-point-in-polygon's People

Contributors

mikolalysenko avatar

Stargazers

 avatar Avraam Piperidis avatar Nikos Pampoukidis avatar

Watchers

James Cloos 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.