text: Check if a line touches or intersects a circle | JavaScript program to check if a line touches or intersects or outside a circle . ; Finding the distance of line from center . ; Checking if the distance is less than , greater than or equal to radius . ; Driver Code
code: function checkCollision ( a , b , c , x , y , radius ) { let dist = ( Math . abs ( a * x + b * y + c ) ) / Math . sqrt ( a * a + b * b ) ; if ( radius == dist ) document . write ( " " ) ; else if ( radius > dist ) document . write ( " " ) ; else document . write ( " " ) ; } let radius = 5 ; let x = 0 , y = 0 ; let a = 3 , b = 4 , c = 25 ; checkCollision ( a , b , c , x , y , radius ) ;