Given two circles and a length K. Find whether we can join two points (one on perimeter of each circle), so that distance between the points is K. (Coordinates of both points need not to be an integer value).
Input: Circle-1 Center (0, 0) Radius = 5 Circle-2 Center (8, 3) Radius = 2 K = 3 Output: Yes Maximum Distance: 15 Minimum Distance: 2
- We have to find the maximum and minimum distance possible between any two points on these circles, if K lies in this range than the answer is Yes otherwise we cannot find such a Line segment.
- To find minimum and maximum distance:
- Case 1: When two circles does not intersect or just touches at one point.
In this scenario, the maximum distance would be distance between centers + Radius (circle 1) + Radius (circle 2). The minimum distance would be distance between centers – Radius(circle 1) – Radius (circle 2).
- Case 2: When the two circles intersect at exactly two points.
In this scenario, the maximum distance would be distance between centers + Radius (circle 1) + Radius (circle 2). The minimum distance would be 0. (We have two points common on both the circles).
- Case 3: When Circle 1 is completely inside Circle 2.
In this scenario, the maximum distance would be distance between centers + Radius (circle 1) + Radius (circle 2). The minimum distance would be Radius (Circle 2) – distance between centers – Radius (Circle 1)
- Case 4: When Circle 2 is completely inside Circle 1.
In this scenario, the maximum distance would be distance between centers + Radius (circle 1) + Radius (circle 2). The minimum distance would be Radius (Circle 1) – distance between centers – Radius (Circle 2)
- Case 5: When both Circles have same center
- Sub Case 1: Radius is also same. Both minimum distance and maximum distance are 0.
Sub Case 2: Radius is different(R1<R2)
Maximum distance is R1+R2
Minimum distance is R2-R1
Below is the implementation of above approach:
- Count of obtuse angles in a circle with 'k' equidistant points between 2 given points
- Queries to check if it is possible to join boxes in a circle
- Equation of circle when three points on the circle are given
- Ways to choose three points with distance between the most distant points <= L
- Find the maximum possible distance from origin using given points
- Check whether two points (x1, y1) and (x2, y2) lie on same side of a given line or not
- Check whether given circle resides in boundary maintained by two other circles
- Number of Integral Points between Two Points
- Program to calculate distance between two points
- Program for distance between two points on earth
- Maximum distance between two points in coordinate plane using Rotating Caliper's Method
- Program to calculate distance between two points in 3 D
- Haversine formula to find distance between two points on a sphere
- Distance between end points of Hour and minute hand at given time
- Pick points from array such that minimum distance is maximized
- Prime points (Points that split a number into two primes)
- Find the radii of the circles which are lined in a row, and distance between the centers of first and last circle is given
- Check whether triangle is valid or not if three points are given
- Find points at a given distance on a line of given slope
- Largest possible value of M not exceeding N having equal Bitwise OR and XOR between them
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.