Archive for December, 2013

Intersection between two circles

Monday, December 30th, 2013

I recently had to find the intersection between two circles as part of a robotics related Java programming project. Since I could not find ready made code on the Internet, I used equations from to write the appropriate code and things done. See here for complete code. Among other things, finding the intersection points of two circles can be used to resolve the inverse kinematics of a two links robot arm. Assuming the following variables:

  • l1: Length of first link
  • x0, y0: Coordinates of the point at which the first link is attached.
  • l2: Length of second link
  • x1, y1: Coordinates of the end effector

The coordinates (x, y) of the point were the two links are joint together (elbow position) can be found by finding the intersection between the two circles with respectively (radius, center x coordinate, center y coordinate): (l1, x0, y0) and (l2, x1, y1).

The angles of the links with respect to the x axis can be found using:

Math.atan2(y1 – y, x1 – x)


You should handle the case were there is no solution (the position is not reachable), or there are two solutions, meaning that the position can be reached by positioning the links in two different ways.

I am aware that there are more sophisticated reverse kinematics equations and that this solution is limited to two links and will certainly not handle cases were the links can be oriented in the z dimension. However, who knows, it could help somebody solve a simple problem without resorting to using the big guns.