📌  相关文章
📜  检查一个点是否在多边形中 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:31.555000             🧑  作者: Mango

代码示例1
function insidePoly(poly, pointx, pointy) {
    var i, j;
    var inside = false;
    for (i = 0, j = poly.length - 1; i < poly.length; j = i++) {
        if(((poly[i].y > pointy) != (poly[j].y > pointy)) && (pointx < (poly[j].x-poly[i].x) * (pointy-poly[i].y) / (poly[j].y-poly[i].y) + poly[i].x) ) inside = !inside;
    }
    return inside;
}