#C11160. Diagonal Intersection in a Parallelogram
Diagonal Intersection in a Parallelogram
Diagonal Intersection in a Parallelogram
You are given a number of parallelograms defined by the coordinates of their four vertices in clockwise order. Your task is to compute the intersection point of the diagonals for each parallelogram.
Recall that in any parallelogram, the diagonals bisect each other. Therefore, the intersection point (x, y) of the diagonals can be computed using the formula:
\( x = \frac{x_1 + x_3}{2} \) and \( y = \frac{y_1 + y_3}{2} \),
where \( (x_1, y_1) \) and \( (x_3, y_3) \) are the coordinates of the first and third vertex respectively.
For each test case, you will be provided with 4 pairs of integers representing the vertices of the parallelogram. Compute the intersection point with a precision of six decimal places.
inputFormat
The input is read from stdin and has the following format:
- The first line contains an integer \(T\) denoting the number of test cases.
- For each test case, there is one line containing 8 integers: \(x_1\), \(y_1\), \(x_2\), \(y_2\), \(x_3\), \(y_3\), \(x_4\), \(y_4\) representing the coordinates of the four vertices of a parallelogram in clockwise order.
outputFormat
For each test case, output a single line on stdout containing two floating-point numbers \(x\) and \(y\) — the coordinates of the intersection point of the diagonals of the given parallelogram. Each number must be printed with exactly six decimal places.
## sample3
0 0 4 0 6 3 2 3
1 1 5 1 6 4 2 4
0 0 6 0 8 4 2 4
3.000000 1.500000
3.500000 2.500000
4.000000 2.000000
</p>