Under construction

Still being built. Things may change

Euclid

Time limit1sMemory limit128 MB

Summary
For each case, find G and H so that ABGH is a parallelogram, H sits on ray AC, and the parallelogram's area equals triangle DEF's area.
Level

Easy3 of 10

Topics
Geometry, Math, Implementation
Solved
No attempts yet

Problem

Euclid wrote down an elaborate construction for the following problem in his notebook. With a computer, though, it is easy to compute.

On the two-dimensional plane there is a segment ABAB, a point CC, and a triangle DEFDEF. The point CC does not lie on line ABAB; equivalently, AA, BB, CC are not collinear, so a non-degenerate parallelogram can be built. You must find points GG and HH such that:

  1. HH lies on the ray that starts at AA and goes through CC.
  2. ABGHABGH is a parallelogram (with its vertices in this order).
  3. The area of parallelogram ABGHABGH equals the area of triangle DEFDEF.

Input

The input consists of several test cases. Each test case is a list of 12 real numbers, none of which has more than 3 digits after the decimal point:

AX AY BX BY CX CY DX DY EX EY FX FY

The coordinates of AA are (AX,AY)(AX, AY), of BB are (BX,BY)(BX, BY), and so on for the other points. Points AA, BB, CC are pairwise distinct and not collinear, and DD, EE, FF form a triangle (they too are pairwise distinct and not collinear, so its area is positive). Every number lies in the closed interval from −1000.0-1000.0 to 1000.01000.0. The input ends with a line of twelve 0.00.0 values.

Output

For each test case, output four real numbers — the coordinates of GG and HH — in the format:

GX GY HX HY

Here G=(GX,GY)G = (GX, GY) and H=(HX,HY)H = (HX, HY). Every value must be rounded to 3 decimal places (rounding at the 4th decimal place) and printed with exactly 3 digits after the decimal point. Print a single space between consecutive numbers.

Examples1

  1. Example 1

    Input
    0 0 5 0 0 5 3 2 7 2 0 4
    1.3 2.6 12.1 4.5 8.1 13.7 2.2 0.1 9.8 6.6 1.9 6.7
    0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
    
    Expected output
    5.000 0.800 0.000 0.800
    13.756 7.204 2.956 5.304