Given two triangles where the second lies inside the first, find the fixed point of the rotation, scaling, and translation map taking one to the other.
Medium6GeometryMathImplementationNo attempts yetTime limit5sMemory limit512 MBHyunwoo has two pictures of a triangle. When he stacks them on the desk, the second picture sits completely inside the first one. Touching the border is allowed. The vertices of the two pictures pair up in the order they are given. The first vertex of the first picture corresponds to the first vertex of the second picture, and the same holds for the second and the third vertex.
Hyunwoo thinks the second picture is the first one rotated, shrunk and moved. That is, he thinks there is a transformation T that applies the following three steps in this order, and that T sends the kth vertex of the first picture to the kth vertex of the second picture for every k.
Flipping is not allowed. If such a T exists, exactly one point keeps its place under T, so exactly one point has the same coordinates in both pictures. Find that point. If no such T exists, for example when the second picture is a mirror image of the first one, print No Solution.
The first line holds the number of test cases N, where 1≤N≤10.
Each test case takes two lines. The first line holds the vertices of the first picture and the second line holds the vertices of the second picture, both in the form x1 y1 x2 y2 x3 y3 with one space between numbers. Every coordinate is an integer between −10000 and 10000.
The three vertices of each triangle are not on one line. The shape of a triangle has no other restriction.
The second triangle lies inside the first triangle, and its area is smaller than the area of the first triangle.
In a test case that has an answer, rounding either coordinate of the answer to six decimal places is never a tie.
Print one line per test case. The line begins with Case #, the test case number and : , joined in this order. Numbering starts at 1.
If the transformation T exists, print after that the x coordinate and the y coordinate of the overlapping point, each rounded to six decimal places and separated by one space. A coordinate that rounds to 0 is printed as 0.000000 with no sign.
If the transformation T does not exist, print No Solution after that.