here cross multiplication is compared instead of division comparison
if ( ( points [ i ] [ 0 ] - points [ first ] [ 0 ] ) * ( points [ second ] [ 1 ] - points [ first ] [ 1 ] ) != ( points [ second ] [ 0 ] - points [ first ] [ 0 ] ) * ( points [ i ] [ 1 ] - points [ first ] [ 1 ] ) && minD > d ) { minD = d ; third = i ; } } Console . WriteLine ( points [ first ] [ 0 ] + " , ▁ " + points [ first ] [ 1 ] ) ; Console . WriteLine ( points [ second ] [ 0 ] + " , ▁ " + points [ second ] [ 1 ] ) ; Console . WriteLine ( points [ third ] [ 0 ] + " , ▁ " + points [ third ] [ 1 ] ) ; }