There are 4 circles with positive integer radius r1, r2, r3 and r4 as shown in the figure below.
The task is to find the radius r4 of the circle formed by three circles when radius r1, r2, r3 are given.
(Note that the circles in the picture above are tangent to each other.)
Input: r1 = 1, r2 = 1, r3 = 1
Input: r1 = 23, r2 = 46, r3 = 69
Approach 1: (Using Binary Search) :
- The policy is to join the centers of all the circles and form 4 triangles
- After the triangles are formed, equate the sum of areas of the three smaller triangles with the main triangle as far as possible using binary search.
Analysis of the mentioned approach:
- This method works because initially there are 4 triangles as pointed in the above image.
- The main triangle with sides and the three smaller triangles with sides .
- The main triangle consists of the small ones so the area of the main triangle is the sum of the areas of the smaller ones.
Forming a search space:
Here binary search. The value for r can be chosen and the sum of the areas of all three smaller triangles can be computed and compared with the area of the main triangle.
- Choosing lower bound
- Choosing upper bound
By intuition, the upper bound value for r4 as the radius of the inscribed circle into the triangle is less than:
Now Binary Search can be applied at the following search space.
Below is the implementation of the problem using the above approach.
Approach 2: (Using Descartes’ Theorem)
- According to Descartes’ Theorem, the reciprocals of radii, or “curvatures”, of these circles satisfy the following relation.
- If are known, one can solve for,
- On solving the above equation;
Below is the implementation of the problem using the above formula.
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Radii of the three tangent circles of equal radius which are inscribed within a circle of given radius
- Radius of the biggest possible circle inscribed in rhombus which in turn is inscribed in a rectangle
- Area of Equilateral triangle inscribed in a Circle of radius R
- Length of direct common tangent between the two non-intersecting Circles
- Length of direct common tangent between two intersecting Circles
- Length of the transverse common tangent between the two non intersecting circles
- Length of the direct common tangent between two externally touching circles
- Area of a square inscribed in a circle which is inscribed in an equilateral triangle
- Area of a square inscribed in a circle which is inscribed in a hexagon
- Area of a circle inscribed in a rectangle which is inscribed in a semicircle
- Number of common tangents between two circles if their centers and radius is given
- Area of the circle that has a square and a circle inscribed in it
- Radius of the circle when the width and height of an arc is given
- Equation of circle from centre and radius
- Find the radii of the circles which are lined in a row, and distance between the centers of first and last circle is given
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.