You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varEPSILON=1e-8;functionisAroundEqual(a,b){returnMath.abs(a-b)<EPSILON;}functioncontain(points,x,y){varw=0;varp=points[0];if(!p){returnfalse;}for(vari=1;i<points.length;i++){varp2=points[i];w+=windingLine(p[0],p[1],p2[0],p2[1],x,y);p=p2;}// Close polygonvarp0=points[0];if(!isAroundEqual(p[0],p0[0])||!isAroundEqual(p[1],p0[1])){w+=windingLine(p[0],p[1],p0[0],p0[1],x,y);}returnw!==0;}functionwindingLine(x0,y0,x1,y1,x,y){if((y>y0&&y>y1)||(y<y0&&y<y1)){return0;}// Ignore horizontal lineif(y1===y0){return0;}vart=(y-y0)/(y1-y0);vardir=y1<y0 ? 1 : -1;// Avoid winding error when intersection point is the connect point of two line of polygonif(t===1||t===0){dir=y1<y0 ? 0.5 : -0.5;}varx_=t*(x1-x0)+x0;// If (x, y) on the line, considered as "contain".returnx_===x ? Infinity : x_>x ? dir : 0;}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: