export function point_in_lasso ( point , vertices ) { let xi , xj , yi , yj , intersect , x = point [ 0 ] , y = point [ 1 ] , is_inside = false ; for ( let i = 0 , j = vertices . length - 1 ; i < vertices . length ; j = i ++ ) { ( xi = vertices [ i ] [ 0 ] ) , ( yi = vertices [ i ] [ 1 ] ) , ( xj = vertices [ j ] [ 0 ] ) , ( yj = vertices [ j ] [ 1 ] ) , ( intersect = yi > y != yj > y && x < ( ( xj - xi ) * ( y - yi ) ) / ( yj - yi ) + xi ) ; if ( intersect ) { is_inside = ! is_inside ; } } return is_inside ; }