Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding all points common to two circles

In Python, how would one find all integer points common to two circles?

For example, imagine a Venn diagram-like intersection of two (equally sized) circles, with center-points (x1,y1) and (x2,y2) and radii r1=r2. Additionally, we already know the two points of intersection of the circles are (xi1,yi1) and (xi2,yi2).

How would one generate a list of all points (x,y) contained in both circles in an efficient manner? That is, it would be simple to draw a box containing the intersections and iterate through it, checking if a given point is within both circles, but is there a better way?

like image 781
Dustin Ingram Avatar asked Apr 28 '10 15:04

Dustin Ingram


People also ask

How do you find the common point between two circles?

Two circles will touch if the distance between their centres, , is equal to the sum of their radii, or the difference between their radii. The centre of one circle will lie on the other circle when d = r 1 or d = r 2 .

Can two circles have three common points?

If two circles have at least 3 points in common then they are the same circle. These three points can't be collinear, since a line only intersects a circle twice. Since they are not collinear they form a triangle and both circles circumscribe the triangle.

How many common points are formed when two circles intersect each other?

Two circles may intersect in two imaginary points, a single degenerate point, or two distinct points. The intersections of two circles determine a line known as the radical line.


1 Answers

Keep in mind that there are four cases here.

  1. Neither circle intersects, meaning the "common area" is empty.
  2. One circle resides entirely within the other, meaning the "common area" is the smaller/interior circle. Also note that a degenerate case of this is if they are the same concentric circle, which would have to be the case given the criteria that they are equal-diameter circles that you specified.
  3. The two circles touch at one intersection point.
  4. The "general" case where there are going to be two intersection points. From there, you have two arcs that define the enclosed area. In that case, the box-drawing method could work for now, I'm not sure there's a more efficient method for determining what is contained by the intersection. Do note, however, if you're just interested in the area, there is a formula for that.
like image 162
Daniel DiPaolo Avatar answered Oct 19 '22 15:10

Daniel DiPaolo