Prime Cut 4
Waahahaha, 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 2 pieces with a flat cut such that the volume of the pieces are equal. But, the Laser-cutter-3000 I got Penny to make cannot rotate, and always cuts the steak on the YZ plane.
I can define an xi value for the laser cutter such that the steak is cut by the plane x=xi.
Can you find the value of xi such that the plane x=xi will bisect the steak?
Input
There are 8 lines, one for each vertex of the steak.
Each line has 3 integers, xyz, giving the 3-dimensional coordinate of the vertex.
It is guaranteed these 8 coordinates form the vertices of a rectangular prism.
Output
Give me the x-value of the plane that divides the steak in 2. Answers with a relative or absolute error less than 10−3 will be accepted.
Constraints
- −104≤x,y,z≤104
Example 1
0 0 0
0 0 1
0 1 0
1 0 0
0 1 1
1 0 1
1 1 0
1 1 1
0.5

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

Here is a diagram of the rotated prism and the plane that bisects it.
Comments0
No comments yet
Be the first to comment.
New comment
Log in to join the discussion.