Editorial for UTS Open '15 #6 - Tetrahedra


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

(Curator's note: Due to new test data, the editorial author no longer passes this problem)

Let's solve each face separately, taking the base area of the face and subtracting the area of the portion of the face which lies inside the other tetrahedron.

Suppose our face is defined by the points A, B, C. The base area is:

\displaystyle \frac{|\overrightarrow{AB} \times \overrightarrow{AC}|}{2}

The face lies on the plane P defined by the point A and the normal vector \overrightarrow{n}:

\displaystyle \overrightarrow{n} = \frac{\overrightarrow{AB} \times \overrightarrow{AC}}{|\overrightarrow{AB} \times \overrightarrow{AC}|}

To find the area of the portion enclosed by the other tetrahedron, consider every pair of points X and Y from the other tetrahedron. If they lie on opposite sides of P (that is, sgn(\overrightarrow{AX} \cdot \overrightarrow{n}) \ne sgn(\overrightarrow{AY} \cdot \overrightarrow{n})), intersect the line \overline{XY} with P and add the intersection to the set of points S.

Since A, B, C, and the members of S all lie on P, we can redefine each point to make the problem 2D. Define \overrightarrow{x} and \overrightarrow{y} as follows:

\displaystyle \overrightarrow{x} = \frac{\overrightarrow{AB}}{|\overrightarrow{AB}|} \quad \overrightarrow{y} = \overrightarrow{x} \times \overrightarrow{n}

Then, for a point Q, its new 2D coordinate is (\overrightarrow{AQ} \cdot \overrightarrow{x}, \overrightarrow{AQ} \cdot \overrightarrow{y}).

The intersection of the projection S and the triangle ABC is a polygon defined by every point Q such that:

  • Q \in S and Q is inside ABC, or
  • Q \in \{A, B, C\} and Q is inside S, or
  • Q is at the intersection of the border of ABC and the border of S

We can find the area of this polygon with the Shoelace Theorem. Subtract it from the base area calculated above to find your answer.

Complexity: \mathcal{O}(1)


Comments

There are no comments at the moment.