Equal Angles

Time limit1sMemory limit128 MB

Summary
For each triangle, compute the two Brocard points, where the angle a point makes with each side in cyclic order stays equal.
Level

Medium7 of 10

Topics
Geometry, Math, Implementation
Solved
No attempts yet

Problem

The All-Equal company places towers on triangular plots so that the angles formed between a tower and the sides of its plot are all equal. For a triangle with vertices A, B, and C there are two such tower positions, call them P and Q:

  • P is the point with ∠PAB=∠PBC=∠PCA\angle PAB = \angle PBC = \angle PCA.
  • Q is the point with ∠QBA=∠QCB=∠QAC\angle QBA = \angle QCB = \angle QAC.

Given the triangle, find P and Q.

Input

The input contains several test cases. Each test case is a single line of six integers:

AX AY BX BY CX CY

Each integer is in the range −100-100 to 100100. They give the three vertices of the triangle: (AX,AY)(AX, AY), (BX,BY)(BX, BY), and (CX,CY)(CX, CY). The points are guaranteed to form a triangle: they are distinct and not all collinear. The input ends with a line of six 0s.

Output

For each test case, output four space-separated real numbers:

PX PY QX QY

where (PX,PY)(PX, PY) and (QX,QY)(QX, QY) are the two requested points. Print each real number with exactly two decimal places (rounded), separated by single spaces. Print no blank lines between outputs.

Examples1

  1. Example 1

    Input
    -4 5 -10 0 7 0
    -15 -5 15 -5 0 21
    0 0 0 0 0 0
    
    Expected output
    -6.26 1.28 -1.96 3.07
    0.01 3.66 -0.01 3.66