# How to find intersection points between two circles?

We have two points (centers of two circles) and their radius in meters, those radius make the circle. We need to find intersection points. For example we have  lat1 = 55.685025, lng1 = 21.118995, r1 = 150 and lat2 = 55.682393, lng2 = 21.121387, r2 = 250. Below you can find our current formula:

``````// Find a and h.
\$a = (\$circle_1_r * \$circle_1_r - \$circle_2_r * \$circle_2_r + \$distance * \$distance) / (2 * \$distance);
\$h = sqrt(\$circle_1_r * \$circle_1_r - \$a * \$a);

// Find P2.
\$circle_3_x = \$circle_1_x + \$a * (\$circle_2_x - \$circle_1_x) / \$distance;
\$circle_3_y = \$circle_1_y + \$a * (\$circle_2_y - \$circle_1_y) / \$distance;

// Get the points P3.
\$intersection_1 = \$this->newLatLngPoint(
(\$circle_3_x + \$h * (\$circle_2_y - \$circle_1_y) / \$distance),
(\$circle_3_y - \$h * (\$circle_2_x - \$circle_1_x) / \$distance)
);

\$intersection_2 = \$this->newLatLngPoint(
(\$circle_3_x - \$h * (\$circle_2_y - \$circle_1_y) / \$distance),
(\$circle_3_y + \$h * (\$circle_2_x - \$circle_1_x) / \$distance)
);
``````

We find such intersection points (yellow markers), however those locations doesn't match in real world. Someone, can help to find where the problem is and how to sort it ?

P.S. Does the altitude (Height above mean sea level) affect the final result? I don't use it but may be should?

• So you want to detect points that are inside the intersection of the buffers circle or within the circle in general? – Curlew Oct 20 '13 at 17:23
• Are these Cartesian circles or geodetic circles? If it's geodetic, simple trig won't work, but you can use simple matrix algebra to find the point of intersection of all segments in the two tables. – Vince Oct 20 '13 at 20:16
• @Curlew i need to get two point, where intersection is. Where one circle intersects other from both sides. I matched it with green squares on the image dropbox.com/s/okhznzpckyzg5j4/… – Kirix Oct 20 '13 at 20:36