function findHoleBridge(hole, outerNode) {
	    var p = outerNode,
	        hx = hole.x,
	        hy = hole.y,
	        qx = -Infinity,
	        m;
	
	    // find a segment intersected by a ray from the hole's leftmost point to the left;
	    // segment's endpoint with lesser x will be potential connection point
	    do {
	        if (hy <= p.y && hy >= p.next.y) {
	            var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
	            if (x <= hx && x > qx) {
	                qx = x;
	                if (x === hx) {
	                    if (hy === p.y) return p;
	                    if (hy === p.next.y) return p.next;
	                }
	                m = p.x < p.next.x ? p : p.next;
	            }
	        }
	        p = p.next;
	    } while (p !== outerNode);
	
	    if (!m) return null;
	
	    if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint
	
	    // look for points inside the triangle of hole point, segment intersection and endpoint;
	    // if there are no points found, we have a valid connection;
	    // otherwise choose the point of the minimum angle with the ray as connection point
	
	    var stop = m,
	        mx = m.x,
	        my = m.y,
	        tanMin = Infinity,
	        tan;
	
	    p = m.next;
	
	    while (p !== stop) {
	        if (hx >= p.x && p.x >= mx &&
	                pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
	
	            tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
	
	            if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) {
	                m = p;
	                tanMin = tan;
	            }
	        }
	
	        p = p.next;
	    }
	
	    return m;
	}
// David Eberly's algorithm for finding a bridge between hole and outer polygon
David Eberly's algorithm for finding a bridge between hole and outer polygon
David Eberly ' s algorithm for finding a bridge between hole and outer polygon
function findHoleBridge(hole, outerNode) {
	    var p = outerNode,
	        hx = hole.x,
	        hy = hole.y,
	        qx = -Infinity,
	        m;
	    do {
	        if (hy <= p.y && hy >= p.next.y) {
	            var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
	            if (x <= hx && x > qx) {
	                qx = x;
	                if (x === hx) {
	                    if (hy === p.y) return p;
	                    if (hy === p.next.y) return p.next;
	                }
	                m = p.x < p.next.x ? p : p.next;
	            }
	        }
	        p = p.next;
	    } while (p !== outerNode);
	    if (!m) return null;
	    if (hx === qx) return m.prev; 
	    var stop = m,
	        mx = m.x,
	        my = m.y,
	        tanMin = Infinity,
	        tan;
	    p = m.next;
	    while (p !== stop) {
	        if (hx >= p.x && p.x >= mx &&
	                pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
	            tan = Math.abs(hy - p.y) / (hx - p.x); 
	            if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) {
	                m = p;
	                tanMin = tan;
	            }
	        }
	        p = p.next;
	    }
	    return m;
	}
function findHoleBridge ( hole , outerNode ) { var p = outerNode , hx = hole . x , hy = hole . y , qx = - Infinity , m ; do { if ( hy <= p . y && hy >= p . next . y ) { var x = p . x + ( hy - p . y ) * ( p . next . x - p . x ) / ( p . next . y - p . y ) ; if ( x <= hx && x > qx ) { qx = x ; if ( x === hx ) { if ( hy === p . y ) return p ; if ( hy === p . next . y ) return p . next ; } m = p . x < p . next . x ? p : p . next ; } } p = p . next ; } while ( p !== outerNode ) ; if ( ! m ) return null ; if ( hx === qx ) return m . prev ; var stop = m , mx = m . x , my = m . y , tanMin = Infinity , tan ; p = m . next ; while ( p !== stop ) { if ( hx >= p . x && p . x >= mx && pointInTriangle ( hy < my ? hx : qx , hy , mx , my , hy < my ? qx : hx , hy , p . x , p . y ) ) { tan = Math . abs ( hy - p . y ) / ( hx - p . x ) ; if ( ( tan < tanMin || ( tan === tanMin && p . x > m . x ) ) && locallyInside ( p , hole ) ) { m = p ; tanMin = tan ; } } p = p . next ; } return m ; }
David Eberly's algorithm for finding a bridge between hole and outer polygon
David Eberly ' s algorithm for finding a bridge between hole and outer polygon
// find a segment intersected by a ray from the hole's leftmost point to the left; // segment's endpoint with lesser x will be potential connection point // hole touches outer segment; pick lower endpoint // look for points inside the triangle of hole point, segment intersection and endpoint; // if there are no points found, we have a valid connection; // otherwise choose the point of the minimum angle with the ray as connection point // tangential