Check if two given circles touch or intersect each other | JavaScript program to check if two circles touch each other or not . ; Driver Code
function circle ( x1 , y1 , x2 , y2 , r1 , r2 ) { let distSq = ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) ; let radSumSq = ( r1 + r2 ) * ( r1 + r2 ) ; if ( distSq == radSumSq ) return 1 ; else if ( distSq > radSumSq ) return - 1 ; else return 0 ; } let x1 = - 10 , y1 = 8 ; let x2 = 14 , y2 = - 24 ; let r1 = 30 , r2 = 10 ; let t = circle ( x1 , y1 , x2 , y2 , r1 , r2 ) ; if ( t == 1 ) document . write ( " " + " " ) ; else if ( t < 0 ) document . write ( " " + " " ) ; else document . write ( " " + " " ) ;