Function: scanline
Purpose: Set a mask for each point in a box that is inside a polygon
Category: MATH
File: scanline.c
Author: M.G.R. Vogelaar
Description: Ordered edge list algorithm from 'Procedural
elements for computer graphics', David F. Rogers
Use: void scanline( int *mask,
int blo[0],
int blo[1],
int bhi[0],
int bhi[1],
float *polyX,
float *polyY,
int ndat );
A polygon is defined by a number of vertices with X coordinates
in 'polX' and Y coordinates in 'polY'. There are 'ndat' vertices
in a polygon. The polygon may be or may not be closed.
A mask is an integer array with as many elements as contained in the
box given by blo and bhi (usually from the BOX= keyword).
This mask represents the data in a subset in a box with limits blo
and bhi. Initially it should be set to zero for each element in the mask.
The function loops over all grid positions in the box and if such a
grid is inside the polygon, then the corresponding position in the
mask is flagged (i.e. one is added to the array element).
Remarks:
Updates: Jul 26, 2004: VOG, Document created.
Apr 15, 2009: VOG, Replaced NINT macro with one that uses floor()
for the calculation of positions.