Square inside a triangle P70549


Statement
 

pdf   zip

Given three points in the plane that form a triangle, compute the maximum possible area of a square inscribed in the triangle.

The four vertices of the square must lie on the three sides of the triangle, with each vertex lying on one of the triangle’s sides.

Input

Input consists of several cases, each with the three points (x,y)(x, y) that define a triangle. Each triangle will be non-degenerate and not right-angled; it will be either acute or obtuse.

Output

For each triangle, print with 4 digits after the decimal point the maximum area af all the squares inscribed in the triangle. The input cases have no precision issues.

Public test cases
  • Input

    -2 -1  2 -1  0 3
    0 0  6 3  3 0
    1.2 2.3  3.4 4.5  4.2 3.8
    

    Output

    4.0000
    1.2500
    0.5787
    
  • Information
    Author
    Ivan Geffner
    Language
    English
    Official solutions
    C++
    User solutions
    C++