Check if a line touches or intersects a circle | PHP 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
< ? php function checkCollision ( $ a , $ b , $ c , $ x , $ y , $ radius ) { $ dist = ( abs ( $ a * $ x + $ b * $ y + $ c ) ) / sqrt ( $ a * $ a + $ b * $ b ) ; if ( $ radius == $ dist ) echo " Touch " ; else if ( $ radius > $ dist ) echo " Intersect " ; else echo " Outside " ; } $ radius = 5 ; $ x = 0 ; $ y = 0 ; $ a = 3 ; $ b = 4 ; $ c = 25 ; checkCollision ( $ a , $ b , $ c , $ x , $ y , $ radius ) ; ? >