Maximum distance between two points in coordinate plane using Rotating Caliper 's Method |  ; Function calculates distance between two points ; Function to find the maximum distance between any two points ; Iterate over all possible pairs ; Update max ; Return actual distance ; Driver code ; Given points ; Function Call
using System ; class GFG { static long dist ( Tuple < int , int > p1 , Tuple < int , int > p2 ) { long x0 = p1 . Item1 - p2 . Item1 ; long y0 = p1 . Item2 - p2 . Item2 ; return x0 * x0 + y0 * y0 ; } static double maxDist ( Tuple < int , int > [ ] p ) { int n = p . Length ; double max = 0 ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = i + 1 ; j < n ; j ++ ) { max = Math . Max ( max , dist ( p [ i ] , p [ j ] ) ) ; } } return Math . Sqrt ( max ) ; } static void Main ( ) { Tuple < int , int > [ ] p = { Tuple . Create ( 4 , 0 ) , Tuple . Create ( 0 , 2 ) , Tuple . Create ( - 1 , - 7 ) , Tuple . Create ( 1 , 10 ) , Tuple . Create ( 2 , - 3 ) , } ; Console . WriteLine ( maxDist ( p ) ) ; } }