There are two circle A and B with their centers C1(x1, y1) and C2(x2, y2) and radius R1 and R2. Task is to check both circles A and B touch each other or not.
Input : C1 = (3, 4) C2 = (14, 18) R1 = 5, R2 = 8 Output : Circles do not touch each other. Input : C1 = (2, 3) C2 = (15, 28) R1 = 12, R2 = 10 Output : Circles intersect with each other. Input : C1 = (-10, 8) C2 = (14, -24) R1 = 30, R2 = 10 Input : -10 8 14 -24 30 10 Output : Circle touch each other.
Distance between centers C1 and C2 is calculated as C1C2 = sqrt((x1 - x2)2 + (y1 - y2)2). There are three condition arises. 1. If C1C2 == R1 + R2 Circle A and B are touch to each other. 2. If C1C2 > R1 + R2 Circle A and B are not touch to each other. 3. If C1C2 < R1 + R2 Circle intersects each other.
Circle touch to each other.
This article is contributed by Dharmendra kumar. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Ratio of the distance between the centers of the circles and the point of intersection of two direct common tangents to the circles
- Ratio of the distance between the centers of the circles and the point of intersection of two transverse common tangents to the circles
- Check whether given circle resides in boundary maintained by two other circles
- Length of rope tied around three equal circles touching each other
- How to check if two given line segments intersect?
- Given n line segments, find if any two segments intersect
- Check if a given circle lies completely inside the ring formed by two concentric circles
- Check if two given Circles are Orthogonal or not
- C Program to check if two given strings are isomorphic to each other
- Minimize count of given operations required to make two given strings permutations of each other
- Puzzle | Connect 9 circles each arranged at center of a Matrix using 3 straight lines
- Check if two arrays are permutations of each other using Mathematical Operation
- Check if two Linked Lists are permutations of each other
- Check if two Integer are anagrams of each other
- Number of common tangents between two circles if their centers and radius is given
- Distance between centers of two intersecting circles if the radii and common chord length is given
- Number of parallelograms when n horizontal parallel lines intersect m vertical parallellines
- Length of the transverse common tangent between the two non intersecting circles
- Program to calculate the area between two Concentric Circles
- Length of the direct common tangent between two externally touching circles
Improved By : vt_m