Expected number of spots on a die visible from a random point in its box, counting a spot only when the segment to the viewer misses the die.
Medium6GeometryProbabilityMathNo attempts yetTime limit1sMemory limit512 MBYou have managed to trap a hornet inside a box lying on top of your dining table. Your playing dice is trapped inside as well, so you cannot retrieve it and continue your game of Monopoly without risking the hornet's wrath. Instead, you pass the time by computing the expected number of spots on the dice visible to the hornet.
The hornet, the dice and the box are located in the standard three-dimensional coordinate system, with the x coordinate growing eastwards, the y coordinate growing northwards and the z coordinate growing upwards. The surface of the table is the xy plane.

Perspective and birds-eye view of the second example input
The dice is a 1×1×1 cube resting on the table with the center of its bottom side exactly at the origin, so the coordinates of its two opposite corners are (−0.5,−0.5,0) and (0.5,0.5,1). The top side of the dice has 5 spots, the south side 1 spot, the east side 3 spots, the north side 6 spots, the west side 4 spots and the bottom side 2 spots. The bottom spots are invisible and irrelevant.
The box is a 5×5×5 cube also resting on the table, with the dice in its interior. The box is given by the coordinates of its bottom side, a 5×5 square.
The hornet hovers at a uniformly random point of the (continuous) space inside the box that is not occupied by the dice. Compute the expected number of spots visible to the hornet. The dice is opaque, so the hornet sees a spot only if the segment connecting the center of that spot to the location of the hornet does not intersect the interior of the dice.
The input consists of 4 lines. The k-th line contains two floating-point numbers xk and yk (−5≤xk,yk≤5), the coordinates of the k-th corner of the bottom side of the box in the xy plane. The corners are given in counterclockwise order and they describe a square whose side length is exactly 5.
The box fully contains the dice. The surfaces of the box and the dice neither intersect nor touch, except along the bottom sides.
Print the expected number of visible spots on one line, rounded to six digits after the decimal point. Always print all six digits. For example, if the answer is exactly 11.25, print 11.250000.