This page is still under construction.

Parts of this page are still being built. What you see may change.

Glide Reflection

Time limit2sMemory limit512 MB

Summary
Given two equal-length segments, find a glide reflection (a reflection in a line plus a parallel translation) that maps one segment onto the other.
Level

Medium7 of 10

Topics
Geometry, Math, Implementation, Brute force
Solved
No attempts yet

Problem

A motion is a transformation of the plane that preserves distances between points: if a motion sends points AA and BB to A1A_1 and B1B_1, then ∣A1B1∣=∣AB∣|A_1B_1| = |AB|.

One kind of motion is a glide reflection. A glide reflection is the composition of a reflection across some line ll and a translation by a vector parallel to ll (the vector may be zero). The figure shows a glide reflection applied to a segment.

A FIGURE GOES HERE

It is known that any segment can be mapped to any other segment of the same length by a glide reflection.

Given the coordinates of two distinct points AA and BB and of two points A1A_1 and B1B_1 that are the same distance apart, find a glide reflection that sends AA to A1A_1 and BB to B1B_1.

Input

The first line contains four integers: the coordinates of two distinct points AA and BB. The second line also contains four integers: the coordinates of two distinct points A1A_1 and B1B_1. It is guaranteed that ∣A1B1∣=∣AB∣|A_1B_1| = |AB|. Every number in the input has absolute value at most 1000.

Output

Print a description of the glide reflection you found.

On the first line print the coordinates of two distinct points lying on the line ll of the reflection, and on the second line print the coordinates of the translation vector parallel to that line. Print real numbers with at least 6 digits after the decimal point.

Examples2

  1. Example 1

    Input
    1 1 3 2
    -1 1 -3 2
    
    Expected output
    0.000000 0.000000 0.000000 1.000000
    0.000000 0.000000
    
  2. Example 2

    Input
    1 1 3 1
    3 -1 5 -1
    
    Expected output
    0.000000 0.000000 1.000000 0.000000
    2.000000 0.000000