Hide

Problem I
Circular Segment Area

Languages en is

You are given a circular segment, represented by a circle at x,y with radius r and two rays from the center of the circle with directions xa,ya and xb,yb, respectively. The rays intersect the circle at two not necessarily distinct points, xp,yp and xq,yq, forming both a chord between the points and an arc on the circle. The arc is the one from xp,yp to xq,yq clockwise. Determine the area that lies between the chord and the arc.

Input

The first line contains three integers x,y,r, where 0r105. The second line contains two integers xa,ya. The third line contains two integers xb,yb.

All coordinates are between 105 and 105, inclusive.

Output

Output the area between of the circular segment. Your output is considered correct if it has at most an absolute or relative error of 104.

Sample Input 1 Sample Output 1
3 3 6
5 2
5 2
0.000000000000
Sample Input 2 Sample Output 2
-5 4 5
-4 3
3 4
7.134954084936
Sample Input 3 Sample Output 3
3 3 6
3 5
5 2
0.806169273811
Sample Input 4 Sample Output 4
0 0 10
100 0
0 100
285.619449019234
Sample Input 5 Sample Output 5
0 0 10000
10000 0
10000 1
314159265.358970978850
Sample Input 6 Sample Output 6
0 0 10000
10000 1
10000 0
0.000008332768
Hide

Please log in to submit a solution to this problem

Log in