Triangle Garden
Time limit1sMemory limit128 MB
Given a triangle's vertices, compute the two foci and string length of the Steiner inellipse tangent at each side's midpoint.
Problem
Sunyoung's landscaping company is known for gardens designed for computer enthusiasts. Its best-known design places a circular pool inside an equilateral triangular terrace so that the pool is tangent to all three sides.
Some customers, however, want a triangular terrace that fits a corner of the garden or an angled boundary instead of an equilateral terrace in the center. For an arbitrary triangular terrace, Sunyoung proposes an elliptical pool tangent to the midpoint of each side of the triangle.
An ellipse can be drawn by fixing two stakes at its foci and using a loop of string. Given the coordinates of the three vertices of the triangle, write a program that outputs the coordinates of the two foci of this ellipse and the required string length. The string length is the sum of the distances from any point on the ellipse to the two foci.
Input
The first line contains an integer N, the number of test cases. (1 ≤ N ≤ 1000)
Each test case is given on one line as six real numbers x1 y1 x2 y2 x3 y3, the coordinates of the three vertices of the triangle.
Output
For each test case, print one line containing fx1 fy1 fx2 fy2 rl, separated by spaces. (fx1, fy1) and (fx2, fy2) are the two foci of the ellipse, and rl is the required string length.
Print the foci so that fx1 <= fx2; if fx1 = fx2, print them so that fy1 <= fy2. Round every value to two digits after the decimal point. If the ellipse is a circle, the two foci are the same point.