Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

判断一个点是不是在多边形内部 #53

Open
wangning0 opened this issue Jun 2, 2018 · 0 comments
Open

判断一个点是不是在多边形内部 #53

wangning0 opened this issue Jun 2, 2018 · 0 comments

Comments

@wangning0
Copy link
Owner

wangning0 commented Jun 2, 2018

function _isInsidePolygon(pt, poly) {  
    for (var c = false, i = -1, l = poly.length, j = l - 1; ++i < l; j = i)  
        ((poly[i].y <= pt.y && pt.y < poly[j].y) || (poly[j].y <= pt.y && pt.y < poly[i].y))  
        && (pt.x < (poly[j].x - poly[i].x) * (pt.y - poly[i].y) / (poly[j].y - poly[i].y) + poly[i].x)  
        && (c = !c);  
    return c;  
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant