Given a triangle and its rotated, translated, and shrunk copy with matching corners, find the unique fixed point of the similarity transformation.
Medium5GeometryMathImplementationNo attempts yetTime limit5sMemory limit512 MBYou have two triangle shaped pictures. The second picture is the first one translated, rotated, and then scaled down by a single factor. The factor is greater than 0 and less than 1. Both pictures lie on a table, and the second picture fits completely inside the first one. The second picture may touch the boundary of the first one.
The three corners of the second triangle correspond in order to the three corners of the first triangle. Widening that correspondence to the whole picture fixes one transformation of the plane. To process the picture you need the point this transformation leaves in place, that is, the position where a point of the first picture and the same point of the scaled picture overlap exactly. Because the factor is less than 1, exactly one such point always exists.
Find the coordinates of that point.
The first line contains the number of test cases N. Each test case takes two lines, and each line gives the coordinates of one triangle as six space separated integers in the format x1 y1 x2 y2 x3 y3. The first of the two lines is the first triangle and the second one is the second triangle. The point (x1,y1) of the first triangle corresponds to the same corner of the picture as (x1,y1) of the second triangle, and (x2,y2) and (x3,y3) correspond the same way.
Limits
For each test case, print one line that starts with Case #t: , where t is the test case number counting from 1. After it print the x coordinate and the y coordinate of the overlapping point, separated by one space.
Print both coordinates rounded to six digits after the decimal point. If a rounded coordinate is 0, print it as 0.000000 with no minus sign. No input has an ambiguous rounding at the seventh digit after the decimal point.