3.25 inte2d – Half-space truncation of arbitrary polygons

The inte2d routine performs geometric clipping of an arbitrary polygon against a half-space defined by the line \(\mathbf{n} \cdot \mathbf{x} + \texttt{c} = 0\). It retains the portion of the polygon lying on the positive side of the line (i.e., where \(\mathbf{n} \cdot \mathbf{x} + \texttt{c} > 0\), consistent with the liquid phase convention) and discards the portion on the negative side.

Fortran:

call inte2d(c,icontn,icontp,ipv,ntp,ntv,vertp,xnc,ync)

C:

inte2d(&c,&icontn,&icontp,ipv,&ntp,&ntv,vertp,&xnc,&ync);

Python:

ntp = np.array(ntp, dtype=np.int32)
ntv = np.array(ntv, dtype=np.int32)
(icontn, icontp) = voft.inte2d(c,ipv,ntp,ntv,vertp,xnc,ync)

Arguments:

c

IN

W_P

scalar representing the signed distance from the PLIC interface to the origin along the unit normal vector \(\boldsymbol{n}\)

icontn

OUT

I_P

number of original polygon vertices satisfying \(\boldsymbol{n} \cdot \boldsymbol{x} + \texttt{c} \le 0\)

icontp

OUT

I_P

number of original polygon vertices satisfying \(\boldsymbol{n} \cdot \boldsymbol{x} + \texttt{c} > 0\)

ipv

INOUT

I_P

array of length \(\texttt{nv}\) storing the vertex indices defining the polygon; updated for the truncated geometry

ntp

INOUT

I_P

maximum vertex index in the connectivity list; updated after truncation

ntv

INOUT

I_P

total number of vertices; updated after truncation

vertp

INOUT

W_P

array of dimensions \(({nv},2)\) storing the \(x,y\)-coordinates of each vertex; updated for the truncated geometry

xnc, ync

IN

W_P

\(x,y\)-components of the unit-length vector \(\boldsymbol{n}\) normal to the PLIC interface pointing towards the liquid phase

Note:

The routine modifies ipv, vertp, ntp, and ntv in place only when both icontn and icontp are positive. If \(\texttt{icontn} = 0\), the entire polygon is retained and the input geometry remains unchanged. If \(\texttt{icontp} = 0\), the retained region is empty, but the input geometry also remains unchanged; the caller must handle this case explicitly. To preserve the original geometry when truncation occurs, make a copy before calling the routine, for example using cppol2d.