Skip to content

Commit

Permalink
a readme
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Jan 1, 2012
1 parent 10a8032 commit 636b9ed
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
41 changes: 41 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
point-in-polygon
================

Determine if a point is inside of a polygon.

This module casts a ray from the inquiry point and counts intersections,
based on
[this algorithm](http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html).

example
=======

``` js
var inside = require('point-in-polygon');
var polygon = [ [ 1, 1 ], [ 1, 2 ], [ 2, 2 ], [ 2, 1 ] ];

console.dir([
inside([ 1.5, 1.5 ], polygon),
inside([ 4.9, 1.2 ], polygon),
inside([ 1.8, 1.1 ], polygon)
]);
```

methods
=======

var inside = require('point-in-polygon')

inside(point, polygon)
----------------------

Return whether `point` is contained in `polygon`.

`point` should be a 2-item array of coordinates.

`polygon` should be an array of 2-item arrays of coordinates.

install
=======

npm install point-in-polygon
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "point-in-polygon",
"description" : "",
"description" : "determine if a point is inside a polygon with a ray intersection counting algorithm",
"version" : "0.0.0",
"repository" : {
"type" : "git",
Expand Down

0 comments on commit 636b9ed

Please sign in to comment.