Previous: clppi Up: ../plot79_c.html Next: clppl3
SUBROUTINE CLPPL2 (NORMAL, XOLD, INCX, YOLD, INCY, NOLD, X XNEW, YNEW, NNEW, MAXNEW) C$ (2-D Polygon Clip to Plane) C$ Clip a 2-D polygon to the visible side of a plane C$ (actually, edge) defined by its normal vector. The output C$ of the clip is a new polygon. Repeated calls can be used C$ to clip a polygon successively against a window boundary. C$ The arguments are: C$ C$ NORMAL(*)......REAL normal vector (A,B,C) defining equation C$ of edge Ax + By + C = 0. The normal points C$ to the visible side of the edge. C$ XOLD(*)........x coordinates of polygon vertices. C$ INCX...........Increment between successive coordinates in C$ XOLD(*) (normally 1). C$ YOLD(*)........y coordinates of polygon vertices. C$ INCY...........Increment between successive coordinates in C$ YOLD(*) (normally 1). C$ NOLD...........Number of polygon vertices. Vertex NOLD is C$ implicitly connected to vertex 1 to close C$ the polygon. C$ C$ The output arguments are: C$ C$ XNEW(*)........x coordinates of clipped polygon vertices. C$ YNEW(*)........y coordinates of clipped polygon vertices. C$ NNEW...........Number of clipped polygon vertices. Vertex C$ NNEW is implicitly connected to vertex 1 to C$ close the polygon. NNEW will usually be C$ less than NOLD, but it may be as large as C$ (3*NOLD+1)/2. This case arises when C$ adjacent vertices lie on opposite sides of C$ the clipping edge, with NOLD/2 visible and C$ (NOLD+1)/2 hidden; each hidden vertex C$ contributes two new vertices on the clipping C$ edge, giving a total of NOLD+1 new vertices, C$ which added to the NOLD/2 old ones is C$ (3*NOLD+1)/2. C$ MAXNEW.........Maximum number of vertex entries available C$ in XNEW(*) and YNEW(*). NNEW is not C$ permitted to exceed this value, and C$ additional vertices simply overwrite the C$ last one. C$ C$ If an increment INCX or INCY is negative, the starting C$ vertex is taken as (1-NOLD)*INC + 1 instead of 1, so that C$ the array is stepped through in reverse order. C$ C$ The algorithm is a variant of one stage of the reentrant C$ polygon clipper originally proposed by I.E. Sutherland and C$ G.W. Hodgman, "Reentrant Polygon Clipping", Comm. ACM 17, C$ 32-42 (1974), in a formulation due to T. Pavlidis, C$ "Algorithms for Graphics and Image Processing", Computer C$ Science Press (1982), Algorithm 15.3, p. 348. However, C$ Pavlidis' intersection computations are reformulated using C$ the dot product parametric line techniques used in CLPPG2. C$ (18-DEC-82)