If point p satisfies the equation of line joining p1 and p2
else { val = ( p [ 1 ] - p1 [ 1 ] ) * ( p2 [ 0 ] - p1 [ 0 ] ) - ( p [ 0 ] - p1 [ 0 ] ) * ( p2 [ 1 ] - p1 [ 1 ] ) ; if ( val == 0 ) if ( ( p [ 0 ] <= Math . max ( p1 [ 0 ] , p2 [ 0 ] ) && ( p [ 0 ] >= Math . min ( p1 [ 0 ] , p2 [ 0 ] ) ) ) && ( p [ 1 ] <= Math . max ( p1 [ 1 ] , p2 [ 1 ] ) && ( p [ 1 ] >= Math . min ( p1 [ 1 ] , p2 [ 1 ] ) ) ) ) return 1 ; } return 0 ; }