
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


drawCircles := proc(x1, y1, x2, y2, r, $)
	local c1, c2, p1, p2;
	use geometry in
		if x1 = x2 and y1 = y2 then
			if r = 0 then
				printf("The circle is a point at [%a, %a].\n", x1, y1);
			else
				printf("The two points are the same. Infinite circles can be drawn.\n");
			end if;
		elif evalf(distance(point(A, x1, y1), point(B, x2, y2))) >r*2 then
				printf("The two points are too far apart. No circles can be drawn.\n");
		else
			circle(P1Cir, [A, r]);#make a circle around the first point
			circle(P2Cir, [B, r]);#make a circle around the second point
			intersection('i', P1Cir, P2Cir);
			#the intersection of the above 2 circles should give you the centers of the two circles you need to draw
			c1 := plottools[circle](coordinates(`if`(type(i, list), i[1], i)), r);#make the first circle 
			c2 := plottools[circle](coordinates(`if`(type(i, list), i[2], i)), r);#make the second circle
			plots[display](c1, c2, scaling = constrained);#draw
		end if;
	end use;
end proc:
 
drawCircles(0.1234, 0.9876, 0.8765, 0.2345, 2.0);
drawCircles(0.0000, 2.0000, 0.0000, 0.0000, 1.0);
drawCircles(0.1234, 0.9876, 0.1234, 0.9876, 2.0);
drawCircles(0.1234, 0.9876, 0.8765, 0.2345, 0.5);
drawCircles(0.1234, 0.9876, 0.1234, 0.9876, 0.0);