Iterate over all points other than the current point
for ( int j = 0 ; j < points . size ( ) ; ++ j ) { if ( j == i ) continue ; int dy = ( ( pair ) points . get ( i ) ) . second - ( ( pair ) points . get ( j ) ) . second ; int dx = ( ( pair ) points . get ( i ) ) . first - ( ( pair ) points . get ( j ) ) . first ;