Closes open polygons (M.A. Mugglestone, S.A. Harding, B.Y.Y. Lee, P.J. Diggle & B.S. Rowlingson)
Option
| PRINT= string token | What to print ( summary); defaultsumm | 
|---|
Parameters
| OLDYPOLYGON= variates | Vertical coordinates of each polygon; no default – this parameter must be set | 
|---|---|
| OLDXPOLYGON= variates | Horizontal coordinates of each polygon; no default – this parameter must be set | 
| NEWYPOLYGON= variates | Vertical coordinates of the closed polygons | 
| NEWXPOLYGON= variates | Horizontal coordinates of the closed polygons | 
Description
A polygonal region of two-dimensional space is represented in Genstat by the coordinates of a sequence of points which define the boundary of the polygon with the last point implicitly connected to the first point. If the first and last pairs of coordinates are the same then the polygon is said to be closed, otherwise it is open. Sometimes it is necessary to work with a closed polygon, for example, when drawing a polygon onto a graphics device as a series of line segments. This procedure takes as input a set of coordinates which define a polygon. The parameters OLDXPOLYGON and OLDYPOLYGON specify variates containing the coordinates. The output of the procedure is a closed polygon, which is identical to the input polygon if it is already closed and otherwise consists of the input polygon with the first pair of coordinates repeated at the end. The coordinates of the closed polygon may be saved using the parameters NEWXPOLYGON and NEWYPOLYGON.
Printed output is controlled by the PRINT option. The default setting of summary prints the horizontal and vertical coordinates of the closed polygon under the headings NEWXPOLYGON and NEWYPOLYGON.
Option: PRINT.
Parameters: OLDYPOLYGON, OLDXPOLYGON, NEWYPOLYGON, NEWXPOLYGON.
Method
A procedure PTCHECKXY is called to check that OLDXPOLYGON and OLDYPOLYGON have identical restrictions. It then checks whether the first and last pairs of coordinates are the same. If they are, the DUPLICATE directive is used to copy OLDXPOLYGON to NEWXPOLYGON and OLDYPOLYGON to NEWYPOLYGON. If they are different, NEWXPOLYGON and NEWYPOLYGON are declared as variates with one more value than their old counterparts, and the EQUATE directive is used to copy the values from OLDXPOLYGON to NEWXPOLYGON and OLDYPOLYGON to NEWYPOLYGON (so that the first element of each old variate is repeated at the end of the corresponding new one).
Action with RESTRICT
If OLDXPOLYGON and OLDYPOLYGON are restricted, only the subset of values specified by the restriction will be included in the calculations.
See also
Procedures: DPOLYGON, PTCLOSEPOLYGON, PTSINPOLYGON.
Commands for: Spatial statistics.
Example
CAPTION 'PTCLOSEPOLYGON example'; STYLE=meta VARIATE xpoly; VALUES=!(0,1,1,0) & ypoly; VALUES=!(0,0,1,1) PTCLOSEPOLYGON OLDYPOLYGON=ypoly; OLDXPOLYGON=xpoly