Problem H
Romeo and Juliet
Input: Standard Input

Output: Standard Output

 

Ah Romeo and Juliet!! Only if they had slightly better Math skills, they might had escaped their sad death and still would have been alive and dancing (They are immortal you know) !!!

 

As their problem can be a problem of your life too, so let’s just pose to you the problem that they were never able to solve, an untold story now for several hundred years.

 

Every Saturday morning Romeo and Juliet used to meet at a random place in a forest hoping that no one would see them there. We cannot simulate the exact behavior of them so we make the following simplifications:

 

(a)    Both Romeo and Juliet started from their own home. The Cartesian coordinates of their homes were (Rx, Ry) and (Jx, Jy) respectively.

(b)   They started from their respective home at the same time.

(c)    They reached their destination at the same time. Actually they did not reach their destination in different time for Juliet’s safety. So if there was a place (point) where they could not reach at the same time then that could not be one of their possible meeting places.

(d)   Arrogant Romeo had a fixed velocity of walking but mild Juliet could change her velocity. In other words we can say that arrogant Romeo walked at a constant speed SR and never changed his initial walking direction and Juliet could vary her walking speed within the limit SJ1 and SJ2 but she also could not change her initial walking direction. Juliet also could not walk faster than Romeo.

(e)    Due to their speed, velocity and other constraints explained above they could not meet at all points.    

(f)    Each morning they selected one location (Location means a point in two dimensional Cartesian coordinate system) randomly from all their possible meeting places.

 

Juliet’s father had an observation tower which tried to monitor the activities of Romeo and Juliet. It was located at (Tx, Ty) and the watchman on top of it could see up to a distance (Tr) around it. So if Romeo and Juliet met within its range, it could report it to Juliet’s father. Given all the information mentioned above and the value of Tx, Ty and Tr your job is to find the probability that Romeo and Juliet’s meeting was seen by the watchman at the observation tower.

 

Input

First line of the input file contains a positive integer N (N<2001) which denotes how many set of inputs follows. Each set of input is given in three lines. The description of each set is given below:

 

The first line of each set contains four integers which denote the values of Rx, Ry, Jx, Jy, (|Rx|≤1000, |Ry|≤1000, |Jx|≤1000, |Jy|≤1000) respectively. The second line contains three integers which denote the values of Tx, Ty (|Tx|≤1000 and |Ty|≤1000) and Tr (1≤Tr≤1000) respectively. The third line contains three integers SR, SJ1, SJ2 (0<SJ1<SJ2≤ SR≤30).

 

The meaning of Rx, Ry, Jx, Jy, Tx, Ty, Tr, SR, SJ1 and SJ2 are given in the problem statement above.

 

Output

For each line of input produce one line of output. This line contains the serial of output followed by floating-point number which denotes the probability that the meeting of Romeo and Juliet was recorded by the watchman of the observation tower of Juliet’s father. This floating point-number should have four digits after the decimal point. Look at the output for sample input for details.

 

Sample Input                              Output for Sample Input

2
40 40 400 80
220 220 280
20 9 12
40 40 400 80
220 220 280
20 9 17
 

Scenario 1: 0.1040

Scenario 2: 0.0172

 


Problem setter: Shahriar Manzoor

Special Thanks: Derek Kisman