Problem D: Rotate a Line Segment

Time limit: 3 sec

In geometry, a line segment is a part of a line that is bounded by two distinct end points, and contains every point on the line between its end points. Examples of line segments include the sides of a triangle or square. More generally, when the end points are both vertices of a polygon, the line segment is either an edge (of that polygon) if they are adjacent vertices, or otherwise a diagonal.Rotate a Line Segment
In this problem, we want to rotate a line segment, anticlockwise by 90 degrees about the middle point of it .
See the example in the figure , (0,3) and (4,1 ) represents a line segment where they are two end points. If we rotate that line segment anticlockwise by 90 degrees about the middle point (2,2) , then new line segment represented by (1,0) and (3,4) where they are two end points.


Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case will contain four integers: Ax, Ay, Bx, By. All the co-ordinates are between -1000 and 1000. (Ax, Ay) denotes A , (Bx, By) denotes B where AB denotes a line segment.


For each case, print the case number and end points of new line segment CD where end points are C (Cx, Cy) and D (Dx, Dy).


Sample Input Sample Output
30 3   4 1

4 5   7 2

0 2   0 -2

Case 1: 1   0 3 4Case 2: 4   2 7 5

Case 3: -2   0 2 0

August Contest, 2014

Problem Setter: Abinash Ghosh



PDF Download link

Leave a Reply

Your email address will not be published. Required fields are marked *