center from radius and two intersections

In part 1 of how-to-draw-circles given arbitrary details about them I discussed how to find a circle’s radius given the length of the arc & chord. Now what?

Well if you are given radius (r) and (x1,y1) and (x2,y2) as two points on the circle’s edge, you can calculate (cx, cy) the center of the circle. Once this information is aquired, you can construct the circle using any graphics rending method you choose.

Quite simple compared to finding the radius actually:

dx = x2 – x1
dy = y2 – y1
d2x = x2² – x1²
d2y = y2² – y1²

q = -dx / dy
s = (d2x + d2y) / (2 * dy)

a = 1 + q²
b = 2(s.q – q.y1 – x1)
c = x1² + y1² – 2.y1.s + s² – r²

cx = (-b +/- sqrt(b² – 4ac)) / (2a)
cy = s +

2 comments on “center from radius and two intersections

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>