nl_tokens: / * http : // mathforum . org / library / drmath / view / 54386 . html
pl_tokens: private boolean contains ( double wantLat , double wantLon , int [ ] rectIndex ) { rectIndex [ 0 ] = Math . <mask> ( Math . min ( rectIndex [ 0 ] , nrows - 1 ) , 0 ) ; rectIndex [ 1 ] = Math . max ( Math . min ( rectIndex [ 1 ] , ncols - 1 ) , 0 ) ; int row = rectIndex [ 0 ] ; int col = rectIndex [ 1 ] ; double x1 = lonEdge . get ( row , col ) ; double y1 = latEdge . get ( row , col ) ; double x2 = lonEdge . get ( row , col + 1 ) ; double y2 = latEdge . get ( row , col + 1 ) ; double x3 = lonEdge . get ( row + 1 , col + 1 ) ; double y3 = latEdge . get ( row + 1 , col + 1 ) ; double x4 = lonEdge . get ( row + 1 , col ) ; double y4 = latEdge . get ( row + 1 , col ) ; // must all have same determinate sign boolean sign = detIsPositive ( x1 , y1 , x2 , y2 , wantLon , wantLat ) ; if ( sign != detIsPositive ( x2 , y2 , x3 , y3 , wantLon , wantLat ) ) return false ; if ( sign != detIsPositive ( x3 , y3 , x4 , y4 , wantLon , wantLat ) ) return false ; if ( sign != detIsPositive ( x4 , y4 , x1 , y1 , wantLon , wantLat ) ) return false ; return true ; }