<p>Given two points on a plane and a radius, usually two circles of given radius can be drawn through the points.</p>
Exceptions:
A radius of zero 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 the radius is equal to zero as well which then collapses the circles to a point.
If the points form a diameter then return a single circle.
If the points are too far apart then no circles can be drawn.Task:
Implement a function that takes two points and a radius and returns the two circles through those points. For each resulting circle, provide the coordinates for the center of each circle rounded to four decimal digits. Return each coordinate as an array, and coordinates as an array of arrays.
For edge cases, return the following:
If points are on the diameter, return one point. If the radius is also zero however, return <code>"Radius Zero"</code>.
If points are coincident, return <code>"Coincident point. Infinite solutions"</code>.
If points are farther apart than the diameter, return <code>"No intersection. Points further apart than circle diameter"</code>.
Sample inputs:
<pre>
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
</pre>
Ref:
<ahref="http://mathforum.org/library/drmath/view/53027.html"title="link: http://mathforum.org/library/drmath/view/53027.html">Finding the Center of a Circle from 2 Points and Radius</a> from Math forum @ Drexel
- text: '<code>getCircles([0.1234, 0.9876], [0.8765, 0.2345], 0.5)</code> should return <code>No intersection. Points further apart than circle diameter</code>'
testString: 'assert.deepEqual(getCircles(...testCases[3]), answers[3], "<code>getCircles([0.1234, 0.9876], [0.8765, 0.2345], 0.5)</code> should return <code>No intersection. Points further apart than circle diameter</code>");'