Clipping an n-dimensional polygon with a halfspace

27 Views Asked by At

Assume that I have a convex polygon in $n > 3$ dimensions, defined by a set of $m$ vertices $\{p_1,\dots,p_m\} \in \mathbb{R}^{n}$. Currently, I have defined my polygon as a set of edges between pairs of vertices.

Now assume further that I have a linear inequality in standard form, i.e., $$a_1x_1 + a_2x_2 + \dots + a_nx_n + b \leq 0, \tag{1}$$ where $a_1,\dots,a_n,b \in \mathbb{R}$. This linear inequality defines a halfspace / hyperplane.

My question: I want to clip my polygon with this halfspace and find the vertices and faces (or edges) of the new polygon. I have some ideas on how to do this in two or three dimensions, but I do not know how to generalize this to $n>3$. Can you help?


What I got so far: I am assuming I defined my polygon in terms of edges (i.e., pairs $(p_i,p_j)$). Feel free to propose a better approach.

  1. If I plug the vertex coordinates into (1), I can learn whether each vertex lies inside (LHS < 0), on (LHS = 0), or outside (LHS > 0) the halfspace of the inequality from its left-hand side (LHS) result.
  2. An edge intersects the hyperplane if its start end end points have opposite signs for their LHS results.
  3. For each intersecting edge, I can compute the intersection point between the edge with the hyperplane. Each intersection point becomes a new vertex.
  4. I can then form a new edge from the edge's vertex with negative LHS and the intersection point.
  5. Then I can remove all vertices and edges associated with positive LHS results. These edges and vertices have either been rendered redundant by step 4 or lie completely outside the halfspace.
  6. However, I then still need to find the edges between the intersection points $p_{1}^{\text{inter}},\dots,p_c^{\text{inter}}$. How can I find these edges?
  7. For simplicity, we can assume that the vertices all lie on a convex hull
  8. I know all intersection points must lie on the hyperplane. In 2D or 3D I can concieve of methods to find the edges between the intersection points. But how could I achieve this in higher dimensions?

As a visual aid in 3D: I am interested in finding the edges between the points where the cube's edges and the hyperplane intersect (see below).

enter image description here