# Maximum number of vertices in intersection of triangle with box

Suppose we have a triangle and a box in 3D. The intersection of the triangle with the (solid) box will be a polygon with some number of vertices (possibly zero). The vertex count will vary according to the precise shapes and positions of the triangle and box.

How can we establish the maximum number of vertices that this polygon could have, for any possible triangle and box?

Intuitively, an upper bound is 9 vertices because each plane of the box can add at most one vertex to the polygon, and the box has 6 planes. But I'm not sure if this is a sharp upper bound; the problem's difficult enough to visualize that I can't convince myself either way. Is there a geometry theorem that answers this?

• What does a polygon with 0 vertices look like? Do you mean how many of the triangle's and box's vertices are in the intersection? – Hao Ye Jul 8 '14 at 0:55
• @HaoYe By "0 vertices" I just mean that the intersection could be empty. No, I don't mean original vertices of the triangle and box, I just mean the corners of the polygon created by intersecting them. – Nathan Reed Jul 8 '14 at 1:36
• I think the problem simplifies to what is the shape of intersection of a triangle and a polygon $P$, where $P$ is the intersection of the box and some plane. You should be able to find some $P$ that is a hexagon, which you can intersect with a triangle to get a nonagon -> 9 vertices. – Hao Ye Jul 8 '14 at 3:32
• A box-plane intersection forming a hexagon is shown halfway down this page, and one can easily truncate three of its vertices with a triangle. – Rahul Jul 8 '14 at 13:25
• @HaoYe That's a good point. Would you mind posting that as an answer? – Nathan Reed Jul 8 '14 at 22:51

1. The problem can be reduced to finding the intersection of the box with the triangle's plane, which produces a polygon, followed by the 2D problem of intersecting that polygon with the triangle.
2. It's possible to cut a box with a plane in such a way that the intersection is a hexagon.

One can easily see that intersecting a triangle with a hexagon can give a nonagon, since each of the triangle's three edges can cut off one vertex of the hexagon. So the upper bound of 9 vertices is fulfilled in such a case.

I agree the maximum is $9$ vertices. It's clear that the points where the triangle enters the box will all be vertices of the polygon. There is a maximum of $6$ such entry points, achieved when each of the $3$ sides enters and exits the box.

As a triangle edge pass through the box, the segment of the edge lying inside the box must form one edge of the polygon. In other words, no extra vertices are gained as the triangle passes inside the box.

When the triangle exits the box, at $A$, say, and then re-enters it, at $B$, say, we want maximal box edges lying between $A$ and $B$ because each such box edge will add an extra vertex to the polygon. We would place $A$ and $B$ therefore on opposite faces of the box but $A$ and $B$ being on different sides of a triangle prevents this. So the next best is to have $A$ and $B$ on adjacent faces of the box, in which case there is one box edge between them and hence one extra vertex for the polygon where that box edge intersects the plane of the triangle.

So we have $6$ vertices where the triangle edges enter the box, plus $3$ extra vertices from the box edges giving us $9$ in total.

It can be seen that this is in fact achievable with a little thought about positioning the triangle relative to the box as just described.

Colour codes:

• Green : sides of triangle inside the cube

• Blue : sides of triangle outside the cube and visible

• Orange: sides of triangle outside the cube and hidden behind the cube

• Purple : sides of polygon on a cube face

The purple and green sides form the polygon.

• "It can be seen that this is in fact achievable with a little thought about positioning the triangle relative to the box as just described." Can you give an example of such a triangle and such a box? – gnzlbg Jul 26 '16 at 11:08
• @gnzlbg Hard to describe in words so I added a picture to my answer. – Mick A Jul 26 '16 at 12:28
• Thanks! I was kind of looking for e.g. 4 points defining a cube, and 3 points defining a triangle for which this is the case, but the picture is really neat, thanks! It helps! – gnzlbg Jul 26 '16 at 13:15

Just an illustration for some regular case represented as code for gnuplot:

set view equal xyz
set autoscale
set xyplane at -1
set xrange [-1:5]
set yrange [-1:5]
set zrange [-1:5]

$cube << EOI 0 0 0 4 0 0 4 0 4 4 4 4 0 4 4 0 4 0 0 0 0 0 0 4 0 0 0 0 0 4 4 0 4 0 0 4 0 4 4 4 4 0 4 4 4 4 4 0 4 0 0 4 4 0 0 4 0 EOI$hexagon << EOI
2 0 0
4 0 2
4 2 4
2 4 4
0 4 2
0 2 0
2 0 0
EOI

$triangle << EOI 5 2 5 2 -1 -1 -1 5 2 5 2 5 EOI set object 1 polygon from 1,1,0 to 2,0,0 to 3,0,1 to 4,1,3 to 4,2,4 to 3,3,4 to 1,4,3 to 0,4,2 to 0,3,1 to 1,1,0 fillstyle solid 0.5 noborder fillcolor rgb 'dark-green'; splot '$$cube' with lines title 'cube', '$$hexagon' with lines title 'hexagon', '$triangle' with lines notitle;


Just save in box_triangle_intersection.plt file and run gnuplot -p box_triangle_intersection.plt.