
Given two points on a plane and a radius, usually two circles of given radius can be drawn through the points.

Exceptions

 r==0.0 should be treated as never describing circles (except in the case where the points are coincident).
 If the points are coincident then an infinite number of circles with the point on their circumference can be drawn, unless r==0.0 as well which then collapses the circles to a point.
 If the points form a diameter then return two identical circles or return a single circle, according to which is the most natural mechanism for the implementation language.
 If the points are too far apart then no circles can be drawn.


Task detail

 Write a function/subroutine/method/... that takes two points and a radius and returns the two circles through those points, or some indication of special cases where two, possibly equal, circles cannot be returned.
 Show here the output for the following inputs:
      p1                p2           r
0.1234, 0.9876    0.8765, 0.2345    2.0
0.0000, 2.0000    0.0000, 0.0000    1.0
0.1234, 0.9876    0.1234, 0.9876    2.0
0.1234, 0.9876    0.8765, 0.2345    0.5
0.1234, 0.9876    0.1234, 0.9876    0.0



Related task

   Total circles area.


See also

   Finding the Center of a Circle from 2 Points and Radius from Math forum @ Drexel


10 FOR i=1 TO 5
20 READ x1,y1,x2,y2,r
30 PRINT i;") ";x1;" ";y1;" ";x2;" ";y2;" ";r
40 GO SUB 1000
50 NEXT i
60 STOP 
70 DATA 0.1234,0.9876,0.8765,0.2345,2.0
80 DATA 0.0000,2.0000,0.0000,0.0000,1.0
90 DATA 0.1234,0.9876,0.1234,0.9876,2.0
100 DATA 0.1234,0.9876,0.8765,0.2345,0.5
110 DATA 0.1234,0.9876,0.1234,0.9876,0.0
1000 IF NOT (x1=x2 AND y1=y2) THEN GO TO 1090
1010 IF r=0 THEN PRINT "It will be a single point (";x1;",";y1;") of radius 0": RETURN 
1020 PRINT "There are any number of circles via single point (";x1;",";y1;") of radius ";r: RETURN 
1090 LET p1=(x1-x2): LET p2=(y1-y2)
1100 LET r2=SQR (p1*p1+p2*p2)/2
1110 IF r<r2 THEN PRINT "Points are too far apart (";2*r2;") - there are no circles of radius ";r: RETURN 
1120 LET cx=(x1+x2)/2
1130 LET cy=(y1+y2)/2
1140 LET dd2=SQR (r^2-r2^2)
1150 LET dx1=x2-cx
1160 LET dy1=y2-cy
1170 LET dx=0-dy1/r2*dd2
1180 LET dy=dx1/r2*dd2
1190 PRINT "(";cx+dy;",";cy+dx;")"
1200 PRINT "(";cx-dy;",";cy-dx;")"
1210 RETURN