Given outer circle radius R and inner circle radius r, making circles from same center and forming boundary between them. Now, given X,Y co-ordinates which denotes center of new circle to be formed with radius rad, your task is to check whether the circle with co-ordinate X,Y as center can fit in the boundary of circles formed or not.
Input : R = 8, r = 4 x = 5, y = 3, rad = 1 Output : Fits Input : R = 8, r = 4 x = 5, y = 3, rad = 3. Output : Doesn't Fit
1 – Doesn’t fits
2 – Fits
The idea is to calculate the distance between the center (0, 0) and the co-ordinates of the circle to be checked. If distance + radius (of the circle to be checked) is less than or equal to Outer Radius and distance – radius (of the circle to be checked) is greater than or equal to Radius of Outer circle – Radius Inner circle
Here is the implementation :
This article is contributed by Rohit Thapliyal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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 if a given circle lies completely inside the ring formed by two concentric circles
- Check if two given circles touch or intersect each other
- Length of rope tied around three equal circles touching each other
- Check if a circle lies inside another circle or not
- Number of common tangents between two circles if their centers and radius is given
- Equation of circle when three points on the circle are given
- Find area of the larger circle when radius of the smaller circle and difference in the area is given
- Length of the transverse common tangent between the two non intersecting circles
- Program to calculate the area between two Concentric Circles
- Length of direct common tangent between the two non-intersecting Circles
- Length of direct common tangent between two intersecting Circles
- Program to calculate area of inner circle which passes through center of outer circle and touches its circumference
- Find the other-end coordinates of diameter in a circle
- Program to find smallest difference of angles of two parts of a given circle
- Path in a Rectangle with Circles
- Maximum points of intersection n circles
- Puzzle | Connect 9 circles each arranged at center of a Matrix using 3 straight lines
- Check if any point overlaps the given Circle and Rectangle
Improved By : vt_m