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 $x_a, y_a$ and $x_b, y_b$, respectively. The rays intersect the circle at two not necessarily distinct points, $x_p, y_p$ and $x_q, y_q$, forming both a chord between the points and an arc on the circle. The arc is the one from $x_p, y_p$ to $x_q, y_q$ clockwise. Determine the area that lies between the chord and the arc.

Input

The first line contains three integers $x, y, r$, where $0 \leq r \leq 10^5$. The second line contains two integers $x_a, y_a$. The third line contains two integers $x_b, y_b$.

All coordinates are between $-10^5$ and $10^5$, 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 $10^{-4}$.

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

Please log in to submit a solution to this problem

Log in