Problem: Find Point

*Difficulty: Baby step

Problem:

Given two points P and Q, output the symmetric point of point P about Q.

Input Format
The first line contains an integer representing the number of testcases
Each test case is a line containing four space separated integers Px Py Qx Qy  representing the (x,y) coordinates of P and Q.

Constraints

1 <= T <= 15
-100 <= x,y <= 100

Output Format
For each test case output x and y coordinates of the symmetric point (each point in a new line).

Sample Input

2
0 0 1 1
1 1 2 2

Sample Output

2 2
3 3

How to solve:
Suppose we got two point A(x,y) and B(x,y) the formula to calculate the coordinates of the middle point is:

midx = (xA + xB )/ 2
midy = (yA + yB)/ 2

We already have the middle point and A, we just need to find xB

xB = 2*midX – xA
yB = 2*midY – yA

Supper easy
Screen Shot 2016-07-15 at 12.30.26 PM

Advertisements