## Nonzero winding rule

The nonzero winding rule computes the winding number of point P with respect to curve C that does not contain the point P. This rule is different for a loop and a polygon.

Given a point Q that travels once around C, the endpoint of a vector from point P to Q, after normalizations, travels along the unit circle centered at point P. If the track of this endpoint were a rubber band that contracted, the rubber band would be wrapped around the circle some number of times. The winding number is the number of wraps. For clockwise wraps, the winding number is negative.

A line is drawn from point P to another point distant from the geometry. This line should not pass through any vertices; otherwise, the results will be ambiguous.
When the line is given parametrically as P + td and
, we define
which is d rotated counterclockwise by 90 degrees.

Intersections of the line with the borders of the polygon are counted with each intersection being assigned a value of +1 or 1 according to the following rule:

- When the dot product of the direction vector of the edge of the polyline with dxab is positive, the value is +1.
- When the dot product is negative, the value is 1. The sum of these values is the winding number of the curve C with respect to point P. Pixels for which the winding number is nonzero are inside the polygon.

This information has been extracted from the following text: Foley, James; vanDam, Andries; Feiner, Steven; Hughes, John. Computer Graphics, Reading, Massachusetts: Addison-Wesley Publishing Company, 1990.

[Contents]
[Previous]
[Next]

Click the icon to mail questions or corrections about this material to Taligent personnel.

Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker