Java Program to Find Distance between Centers of Two Intersecting Circles if the Radii and Common Chord Length is Given

bookmark

import java.io.*;
class Main
{
    public static void main(String [] args)
    {
        double R1 = 20;
        double R2 =  10; 
        double AB = 7;
        // formula to find distance between center of 2 circles
        double D = Math.sqrt( R1*R1 -  (AB/2)*(AB/2)) + Math.sqrt( R2*R2 -  (AB/2)*(AB/2)) ;
        System.out.println("The distance between 2 centers is  " + D);
    }
}
 


Output:

The distance between 2 centers is 29.058865665112812