# Demo entry 6635650

**算法**

Submitted by **anonymous**
on Aug 18, 2017 at 09:10

Language: JavaScript. Code size: 454 Bytes.

function pointInsidePolygon (pos, points) { const [x, y] = pos; let inside = false; for (let i = 0, j = points.length - 1; i < points.length; j = i++) { let [xi, yi] = points[i]; let [xj, yj] = points[j]; var intersect = ((yi > y) != (yj > y)) && (x < (xj - xi) * (y - yi) / (yj - yi) + xi); if (intersect) inside = !inside; } return inside; }

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.