Under construction

Still being built. Things may change

Circle Through Three Points

Time limit1sMemory limit128 MB

Summary
For each line of three points, compute the circle through them and print its center-radius and general equations with signs adjusted.
Level

Easy3 of 10

Topics
Geometry, Math, Implementation, Brute force
Solved
No attempts yet

Problem

Given the Cartesian coordinates of three points on a plane, find the equation of the circle that passes through all three of them. The three points are guaranteed not to lie on a single straight line.

Report the circle in two forms. One is the standard (center–radius) form

(x−h)2+(y−k)2=r2(x - h)^2 + (y - k)^2 = r^2

and the other is the general form

x2+y2+cx+dy−e=0x^2 + y^2 + cx + dy - e = 0

Input

Each line of input contains the xx and yy coordinates of three points AA, BB, and CC, listed in the order AxA_x, AyA_y, BxB_x, ByB_y, CxC_x, CyC_y. The coordinates are real numbers separated from one another by one or more spaces. Read lines until the end of the input.

Output

For each input line, print the two required equations on two consecutive lines, using the format shown in the examples. The values hh, kk, rr, cc, dd, and ee must each be printed with exactly three digits after the decimal point.

Adjust the plus and minus signs so that no number is preceded by two signs. For example, when k=−2k = -2 the term is written (y + 2.000) rather than (y - -2.000). Every +, -, and = sign must be surrounded by exactly one space on each side, and no other spaces may appear inside an equation.

Separate consecutive equation pairs with a single blank line.

Hint

Examples3

  1. Example 1

    Input
    7.0 -5.0 -1.0 1.0 0.0 -6.0
    1.0 7.0 8.0 6.0 7.0 -2.0
    
    Expected output
    (x - 3.000)^2 + (y + 2.000)^2 = 5.000^2
    x^2 + y^2 - 6.000x + 4.000y - 12.000 = 0
    
    (x - 3.921)^2 + (y - 2.447)^2 = 5.409^2
    x^2 + y^2 - 7.842x - 4.895y - 7.895 = 0
    
  2. Example 2

    Input
    18 5 5 18 0 -7
    
    Expected output
    (x - 5.000)^2 + (y - 5.000)^2 = 13.000^2
    x^2 + y^2 - 10.000x - 10.000y - 119.000 = 0
    
  3. Example 3

    Input
    4 2 -6 12 -14 -4
    
    Expected output
    (x + 6.000)^2 + (y - 2.000)^2 = 10.000^2
    x^2 + y^2 + 12.000x - 4.000y - 60.000 = 0