| ||A team of geologists is searching a site expected to have a rich mineral deposit. Both the site and the deposit can be represented by convex polygons such that the deposit polygon is located completely inside the site polygon. The coordinates of the site polygon's vertices will be given in the ints siteX and siteY, and the coordinates of the deposit polygon's vertices will be given in the ints depositX and depositY. Each of these two sets of points is given in counter-clockwise order, starting from an arbitrary initial vertex. The size of the team is very small compared to the sizes of the site and deposit, so we shall represent the team by a point.
Since the site is so large, the team cannot explore all of it. Instead, they will start at a point chosen uniformly at random from all points on the site boundary, and move in a straight line towards a point on the site boundary which is farthest away from the starting point. If several points on the boundary are farthest away from the starting point, the team chooses one of them with equal probability. The team's analysts are hoping that this method will give the team a high chance of finding the deposit.
Let us say that the team finds the deposit if the team's path and the deposit region intersect in at least one point. Return the probability that the team finds the deposit.
|Parameters:||int, int, int, int|
|Method signature:||double successProbability(int siteX, int siteY, int depositX, int depositY)|
|(be sure your method is public)|
|-||The returned value must have an absolute or relative error less than 1e-9.|
|-||A polygon is convex if it does not intersect itself, and every straight line joining any two interior points of the polygon is entirely contained in the polygon's interior.|
|-||siteX, siteY, depositX and depositY will each contain between 3 and 50 elements, inclusive.|
|-||siteX and siteY will contain the same number of elements.|
|-||depositX and depositY will contain the same number of elements.|
|-||Each element of siteX, siteY, depositX and depositY will be between -1000 and 1000, inclusive.|
|-||The points (siteX[i], siteY[i]), taken in order, will describe a counterclockwise traversal of vertices in a convex polygon.|
|-||The points (depositX[i], depositY[i]), taken in order, will describe a counterclockwise traversal of vertices in a convex polygon.|
|-||In each of the polygons, no three adjacent vertices will lie on the same line.|
|-||The deposit polygon will be located entirely in the interior of the site polygon. The boundaries of the two polygons will not intersect.|
|In the picture below, the outer square represents the site and the inner square represents the deposit. The blue sections of the site's perimeter consist of points which would lead to failure if they were chosen as the start of the team's path. The coordinates of these ranges are given (in blue). The white sections show the starting points for a successful path.|
|Here, the team will always find the deposit.