Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

checking a point is in polygon

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;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery datepicker set default date 
Javascript :: array sort by key javascript 
Javascript :: Javascript looping through table 
Javascript :: cypress support ability to set viewport in `before` 
Javascript :: URL scheme "localhost" is not supported. 
Javascript :: install json-server 
Javascript :: props to react router link 
Javascript :: li key attribute 
Javascript :: hello world in jsp 
Javascript :: inner content 
Javascript :: sequelize update record 
Javascript :: too many open files react native 
Javascript :: display am pm in javascript 
Javascript :: get DOM node with xpath 
Javascript :: validatorjs get all errors 
Javascript :: javascript print out 
Javascript :: js not equal to null 
Javascript :: random in a range js 
Javascript :: run react app in react 18 
Javascript :: replace object in array javascript 
Javascript :: discordjs delete all messages in channel 
Javascript :: remove everything except alphabet and number js 
Javascript :: function use for placing bet 
Javascript :: vue test form input 
Javascript :: express js server 
Javascript :: get a href value javascript 
Javascript :: double question mark javascript 
Javascript :: onload multiple functions 
Javascript :: ajax load spesific element from another page 
Javascript :: get 5 months after date in javascript 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =