5 Tiling Geometric Primitives
5.5 Geometric Models
The edge-seeking algorithm is a method of tiling convex figures. The algorithm itself does not define the convex figures. It is important for any rendering system to provide precise defini- tions of its primitives so its applications can understand the ramifications of the sampling inher- ent in the scan conversion process. This section defines the geometric primitives not through algorithmic descriptions, but through higher-level models of the sampling process.
5.5.1 Quadrilateral Model
An important characteristic of a quadrilateral scan conversion algorithm is the description of exactly which pixels are considered ‘inside’ the quadrilateral -- this is the quadrilateral model. The quadrilateral scan conversion process represents a transformation from a mathematical rep- resentation to a discrete pixel representation. In other words, scan conversion is the execution of an algorithm for determining the set of pixels that are inside a quadrilateral given its geomet- ric description. Antialiasing is ignored: insidedness of a pixel in a quadrilateral is a boolean decision. That is not to say that PixelVision quadrilaterals are black and white. The premise is simply that the resolution is fixed (no antialiasing) and that the quadrilateral model is distinct from the pixel values placed in graphics memory.
An important property in scan converting quadrilaterals is that adjacent quadrilaterals touch cleanly. The pixels along an edge shared by adjacent quadrilaterals should be included in one and only one of the quadrilaterals. Relating this to the transformation implicit in scan conver- sion, objects that are mutually exclusive in geometric space should remain mutually exclusive in pixel space.
The PixelVision’s quadrilateral model states that a quadrilateral is composed of the set of all pixels whose coordinate values are inside the quadrilateral’s boundary. The only pixels whose insidedness is in question are those whose coordinate values lie directly on one of the quadrilat- eral’s edges. Keeping in mind our goal of cleanly touching quadrilaterals, it seems reasonable to simply include left edges but not right. Applying the math from the half-space chapter, if the half-space equation evaluates to zero (indicating that a pixel is exactly on the edge), then it is marked as a ‘+’ for a left edge, and a ‘-’ for a right edge. The rendering subsystem examines edges in a clockwise direction to guarantee that the positive side of a half-space is always to- wards the inside of the quadrilateral; therefore, a right edge has the property that its second ver- tex has a larger y value than its first vertex, while the opposite is true of a left edge.
Figure 5-11 Quadrilateral Model
The convention of including pixels on the left edge but not the right edge does not define insidedness of pixels on horizontal edges, since the definitions of left and right break down. For horizontal edges, the PixelVision quadrilateral model includes top edges, and excludes bot- tom edges. A bottom edge is a horizontal edge whose second vertex is to the left of its first vertex; a top edge is any other horizontal edge. Minimum and maximum vertices belonging to both an edge that is included and an edge that is excluded are excluded.
5.5.2 Line Model
To better understand the design of the PixelVision’s line algorithm first requires a description of what is generally considered the best looking set of pixels describing a line segment on a raster device. For a one-pixel-wide line segment, Bresenham’s integer algorithm defines these pixels. The PixelVision algorithm generates the same pixel set as Bresenham’s algorithm. A line segment from (x1,y1) to (x2,y2) includes pixels as described below.
If the absolute value of (x2-x1) is greater than the absolute value of (y2-y1), then x is the major axis of the line and y is the minor axis. If x is the major axis , the pixel representation for the line segment is defined as the set of pixels, one for each discrete value of x between x1 and x2, that are closest to the line. One and only one pixel is chosen for each value of x between x1 and x2. In the case where two pixels are equidistant from the line, a screen relative decision is made so that a line drawn from (x1,y1) to (x2,y2) is the same as a line drawn from (x2,y2) to (x1,y1). An analogous definition holds for lines where y is the major axis and x is the minor axis.
Bresenham’s algorithm is an efficient method for choosing these pixels; however, it makes no use of the parallelism and high bandwidth to graphics memory available in the PixelVision ren- dering subsystem. PixelVision generates the same pixels as Bresenham’s algorithm by model- ing a line as a thin polygon. An infinite one-pixel-wide line can be modeled as the intersection of two half-spaces with parallel boundaries separated by one pixel. Two more half-spaces rec-
ognize the endpoints of the line segment. If the x axis is the major axis of a line segment from (x1, y1) to (x2, y2), then the two parallel half-space boundaries are defined by (x1, y1-.5) to (x2, y2-.5) and (x2, y2+.5) to (x1, y1+.5).1 If the y axis is the major axis, then the two half-spaces are (x1-.5, y1) to (x2-.5, y2) and (x2+.5, y2) to (x1+.5, y1). Depending on the direction of the line segment (which endpoint is the first endpoint), the half-space orientation may need to be reversed. The endpoints are detected by two more half-spaces as shown in figure 5-12.
Figure 5-12 Model of a line segment. The top and bottom edges are exactly one pixel apart along the minor axis of the line.
The line model includes all pixels that are inside the quadrilateral established by the four half- spaces. Just as the boundary pixels are special cases in the quadrilateral model, so are they in the line model. The first endpoint of a line segment is always included as part of the line. In- clusion of the second endpoint is selectable by the line cap style in the rendering subsystem. To guarantee that one and only one pixel is chosen per step along the major axis, one of the other two half-space evaluators should include boundary pixels and the other should not. In sum- mary, the half-space evaluators act as follows:
Endpoint 1 half-space: include boundary pixels
Endpoint 2 half-space: inclusion of boundary pixels determined by line cap style top half-space for x-major lines, left for y-major: include boundary pixels
bottom half-space for x-major lines, right for y-major: exclude boundary pixels
In addition to rendering one-pixel-wide lines, the PixelVision can render wide lines. The wide line model is identical to the one-pixel-wide line model, except instead of offsetting vertices by .5 from the true line, they are offset by a user-specified width. Wide lines are particularly use- ful for implementing anti-aliased line algorithms.
5.5.3 Point Model
A single vertex (x, y) parametrizes a point to the PixelVision rendering subsystem. The model of a point is based on the model of a quadrilateral. Specifically, a point is a quadrilateral with vertices (x, y), (x+1.0, y), (x+1.0, y+1.0), and (x, y+1.0). Here, "1.0" represents one pixel, or eight subpixel units.