Instruções

Círculos de raio determinado através de dois pontos

Dados dois pontos em um plano e num raio, geralmente dois círculos de um determinado raio podem ser traçados através dos pontos. Exceções: <ul> <li>A radius of zero should be treated as never describing circles (except in the case where the points are coincident).</li> <li>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.</li> <li>If the points form a diameter then return a single circle.</li> <li>If the points are too far apart then no circles can be drawn.</li> </ul>

O que fazer:

Implementa uma função que recebe dois pontos e um raio e retorna os dois círculos através desses pontos. Para cada círculo resultante, forneça as coordenadas para o centro de cada círculo arredondadas para quatro casas decimais. Retorne cada coordenada como um array, e as coordenadas como um array de arrays. Para casos extremos, retorne o seguinte: <ul> <li>If points are on the diameter, return one point. If the radius is also zero however, return <code>"Radius Zero"</code>.</li> <li>If points are coincident, return <code>"Coincident point. Infinite solutions"</code>.</li> <li>If points are farther apart than the diameter, return <code>"No intersection. Points further apart than circle diameter"</code>.</li> </ul> Entradas de exemplo: <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>

Critérios de Aceitação:

Testes:

  • `getCircles` deve ser uma função.
  • `getCircles([0.1234, 0.9876], [0.8765, 0.2345], 2.0)` deve retornar `[[1.8631, 1.9742], [-0.8632, -0.7521]]`.
  • `getCircles([0.0000, 2.0000], [0.0000, 0.0000], 1.0)` deve retornar `[0, 1]`
  • `getCircles([0.1234, 0.9876], [0.1234, 0.9876], 2.0)` deve retornar `Coincident point. Infinite solutions`
  • `getCircles([0.1234, 0.9876], [0.8765, 0.2345], 0.5)` deve retornar `No intersection. Points further apart than circle diameter`
  • `getCircles([0.1234, 0.9876], [0.1234, 0.9876], 0.0)` deve retornar `Radius Zero`

Console