Asteroids
Time limit1sMemory limit128 MB
Given two convex polyhedra, find rotations and a touching translation that minimize the distance between their centers of mass without overlap.
- Level
Hard9 of 10
- Topics
- Geometry, Math, Binary search
- Solved
- No attempts yet
Problem
The Association of Collision Management (ACM) is planning a controlled collision of two asteroids. The asteroids are brought together slowly and touch at a negligible speed; ACM expects them to attach to each other and form a single stable object.
Each asteroid has the shape of a convex polyhedron. To increase the chance of success, ACM wants to join the asteroids so that their centers of mass end up as close as possible. To do this the operators may rotate and translate each asteroid independently before joining them, but the two solids may never overlap — they may only touch on their surfaces.
Determine the minimum possible distance between the two centers of mass.
When computing a center of mass, both asteroids are assumed to have constant density.
Input
The input describes two convex polyhedra.
Each description begins with a line containing an integer , the number of vertices of the polyhedron (). The next lines each contain three integers , , — the coordinates of one vertex ().
The given points are guaranteed to be exactly the vertices of a convex polyhedron: no point lies in the convex hull of the others, and each polyhedron is non-degenerate (it has positive volume). The two polyhedra have no common points.
Output
Print a single number: the minimum achievable distance between the two centers of mass, rounded to exactly 6 digits after the decimal point.