public class PointCircleTest {

    public static double distance(PointCircle pta , PointCircle ptb){

        double insqrtx = Math.pow(pta.getX() - ptb.getX(), 2) ;
        double insqrty = Math.pow(pta.getY() - ptb.getY(), 2) ;

        double out = Math.sqrt(insqrtx + insqrty) ;

        return out ;
    }


    public static void main(String[] args){

        double radius = Double.parseDouble(args[0]) ;
        double side = radius * Math.sqrt(3) ;

        int nruns = Integer.parseInt(args[1]) ;

        int count = 0 ;
        double theta1 = 0 ;
        double theta2 = 0 ;

        double dist = 0 ;

        PointCircle pta = new PointCircle(radius , theta1) ;
        PointCircle ptb = new PointCircle(radius , theta2) ;

        for (int i = 0 ; i < nruns ; i++){

            theta1 = 2.0 * Math.PI * Math.random() ;
            theta2 = 2.0 * Math.PI * Math.random() ;

            pta.setX(radius,theta1) ;
            pta.setY(radius,theta1) ;

            ptb.setX(radius,theta2) ;
            ptb.setY(radius,theta2) ;

            dist = distance(pta , ptb) ;

            if(dist > side)
                count++ ;

            // // if you want to see the output step by step
            // System.out.printf("pta = (%f,%f); ptb = (%f,%f); distance = %f ; count = %d%n",
            //                   pta.getX() ,
            //                   pta.getY() ,
            //                   ptb.getX() ,
            //                   ptb.getY() ,
            //                   dist ,
            //                   count ) ;

        }

        System.out.printf("The ratio of points that verify the Bertrand's Chord is %f.%n%n" , (count + 0.0)/nruns ) ;

    }
}
