Prime Cut 4
View as PDFWaahahaha, I'm a Wario!
I need your help to win a game. I have steak that is in the shape of a rectangular prism with an
arbitrary position, rotation and scale. I want to cut the steak into pieces with a flat cut
such that the volume of the pieces are equal. But, the Laser-cutter-
I got Penny to make
cannot rotate, and always cuts the steak on the YZ plane.
I can define an value for the laser cutter such that the steak is cut by the plane
.
Can you find the value of such that the plane
will bisect the steak?
Input
There are lines, one for each vertex of the steak.
Each line has integers,
, giving the
-dimensional coordinate of the vertex.
It is guaranteed these coordinates form the vertices of a rectangular prism.
Output
Give me the x-value of the plane that divides the steak in . Answers with a relative or absolute
error less than
will be accepted.
Constraints
Example 1
Input
0 0 0
0 0 1
0 1 0
1 0 0
0 1 1
1 0 1
1 1 0
1 1 1
Output
0.5

Here is a diagram of the prism and the plane that bisects it.
Example 2
Input
0 4 0
3 0 0
3 0 6
7 3 6
7 3 0
4 7 0
0 4 6
4 7 6
Output
3.5

Here is a diagram of the rotated prism and the plane that bisects it.
Comments