Intersection of two circles

Posted: July 3, 2011 in Java

Intersection of two circles

The following note describes how to find the intersection point(s) between two circles on a plane, the following notation is used. The aim is to find the two points P3 = (x3, y3) if they exist.

First calculate the distance d between the center of the circles. d = ||P1 – P0||.

  • If d > r0 + r1then there are no solutions, the circles are separate.
  • If d < |r0 – r1| then there are no solutions because one circle is contained within the other.
  • If d = 0 and r0 = r1then the circles are coincident and there are an infinite number of solutions.

Considering the two triangles P0P2P3 and P1P2P3we can write

a2 + h2 = r02 and b2 + h2 = r12Using d = a + b we can solve for a,

a = (r02 – r12 + d2) / (2 d)

It can be readily shown that this reduces to r0 when the two circles touch at one point, ie: d = r0 + r1

Solve for h by substituting a into the first equation, h2 = r02 – a2

So

P2 = P0 + a ( P1 – P0 ) / dAnd finally, P3 = (x3,y3) in terms of P0 = (x0,y0), P1 = (x1,y1) and P2 = (x2,y2), is

x3 = x2 +- h ( y1 – y0) / d

y3 = y2 -+ h ( x1 – x0 ) / d

 

Reference

http://paulbourke.net/geometry/2circle/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s