Previous Next


                                          233
SECTION 4.4                                             Path Construction and Painting



Note: The method just described does not specify what to do if a path segment coin-
cides with or is tangent to the chosen ray. Since the direction of the ray is arbitrary,
the rule simply chooses a ray that does not encounter such problem intersections.

For simple convex paths, the nonzero winding number rule defines the inside
and outside as one would intuitively expect. The more interesting cases are those
involving complex or self-intersecting paths like the ones shown in Figure 4.10.
For a path consisting of a five-pointed star, drawn with five connected straight
line segments intersecting each other, the rule considers the inside to be the en-
tire area enclosed by the star, including the pentagon in the center. For a path
composed of two concentric circles, the areas enclosed by both circles are consid-
ered to be inside, provided that both are drawn in the same direction. If the circles
are drawn in opposite directions, only the doughnut shape between them is in-
side, according to the rule; the doughnut hole is outside.




                      FIGURE 4.10 Nonzero winding number rule


Even-Odd Rule

An alternative to the nonzero winding number rule is the even-odd rule. This rule
determines whether a point is inside a path by drawing a ray from that point in
any direction and simply counting the number of path segments that cross the
ray, regardless of direction. If this number is odd, the point is inside; if even, the
point is outside. This yields the same results as the nonzero winding number rule
for paths with simple shapes, but produces different results for more complex
shapes.

Figure 4.11 shows the effects of applying the even-odd rule to complex paths. For
the five-pointed star, the rule considers the triangular points to be inside the path,

Previous Next