Ultraviolet A 10250-the other two trees

Source: Internet
Author: User
Tags integer numbers

Problem E

The other two trees

Input:Standard Input

Output:Standard output

Time limit:2 seconds

 

You have a quadrilateral shaped land whose opposite fences are of equal length. you have four neighbors whose lands are exactly adjacent to your four fences, that means you have a common fence with all of them. for example if you have a fence of LengthD
In one side, this fence of LengthDIs also the fence of the adjacent neighbor on that side. The adjacent neighbors have no fence in common among themselves and their lands also don't intersect. The main difference between their land and your
Land is that their lands are all square shaped. all your neighbors have a tree at the center of their lands. given the Cartesian coordinates of trees of two opposite neighbors, you will have to find the Cartesian coordinates of the other two trees.

 

Input

The input file contains several lines of input. Each line contains four floating point or integer numbersX1, Y1, X2, Y2,Where
(X1, Y1), (X2, Y2)Are the coordinates of the trees of two opposite neighbors. input is terminated by end of file.

 

Output

For each line of input produce one line of output which contains the line
"Impossible ."
Without the quotes, if you cannot determine the coordinates of the other two trees. Otherwise, Print four floating point numbers separated by a single space with ten digits after the decimal pointAx1, Ay1, ax2, ay2,Where
(Ax1, AY1)And(Ax2, ay2)Are the coordinates of the other two trees. The output will be checked with special judge program, so don't worry about the ordering of the points or small precision errors. The sample output will
Make it clear.

 

Sample Input

10 0-10 0

10 0-10 0

10 0-10 0

 

Sample output

0.0000000000 10.0000000000 0.0000000000-10.0000000000

0.0000000000 10.0000000000-0.0000000000-10.0000000000

0.0000000000-10.0000000000 0.0000000000 10.0000000000

I started to tell us that the point of A and B is C and the point of D is 0;

Obviously there are (vectors)

AB and OC Point product is 0, OC and OD Point product is 0;

A (x1, Y1) B (X2, Y2) C (x, y)

(X-x1) * (x-x2) + (y-y1) * (y-y2) = 0
(X-(X1 + x2)/2) * (x1-x2) + (Y-(Y1 + y2)/2) * (y1-y2) = 0

Simplicity is annoying ~~~~ (>_< )~~~~ ,

Later, I saw someone else doing this with vector rotation. I have never learned this before ~~~~ (>_< )~~~~ Baidu

 

Here is a special 90-degree value, which can directly calculate the vector from point C to the origin. Then, the coordinate value of the midpoint is the coordinate value of point C.

# Include <stdio. h>
Void main ()
{Double X1, Y1, X2, Y2, X3, Y3, X4, Y4, CX, Cy;
While (scanf ("% lf", & X1, & Y1, & X2, & Y2 )! = EOF)
{If (x1 = X2 & Y1 = Y2)
Printf ("Impossible. \ n ");
Else
{Cx = (X1 + x2)/2; Cy = (Y1 + y2)/2;
X1-= Cx; x2-= Cx; Y1-= Cy; Y2-= Cy;
X3 =-Y1; Y3 = x1; X4 =-X3; Y4 =-Y3;
Printf ("% lf \ n", X3 + cx, Y3 + cy, X4 + cx, Y4 + cy );
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.