Scaled Triangle (Small)
Time limit5sMemory limit512 MB
Given a triangle and its rotated, translated, and shrunk copy with matching corners, find the unique fixed point of the similarity transformation.
- Level
Medium5 of 10
- Topics
- Geometry, Math, Implementation
- Solved
- No attempts yet
Problem
You 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 and less than . 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 , exactly one such point always exists.
Find the coordinates of that point.
Input
The first line contains the number of test cases . 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 of the first triangle corresponds to the same corner of the picture as of the second triangle, and and correspond the same way.
Limits
- Every coordinate is an integer between and .
- The three points of one triangle are never collinear.
- Every triangle is an isosceles right triangle, so its angles are 45 degrees, 45 degrees, and 90 degrees.
- The second triangle is the first triangle translated, rotated, and scaled by a factor greater than and less than , and it lies inside the first triangle.
Output
For each test case, print one line that starts with Case #t: , where t is the test case number counting from . After it print the coordinate and the 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 , print it as 0.000000 with no minus sign. No input has an ambiguous rounding at the seventh digit after the decimal point.