Computer Graphics (ii) OUTPUT element _10_ Polygon filling Area _3_ Internal-external test

Source: Internet
Author: User

Internal-External testing
various graphics processing often requires the identification of an object's internal area. It is often easy to identify simple objects such as convex polygons, circles, or ellipses.. But sometimes we have to deal with more complex objects. For example, we maydescribes a complex fill area with intersecting edges as shown in Figure 3.46. In this shape, which part of the XY plane is the "interior" of the object boundary, and which part is "outside" is not always at a glance. parity rules and non-0 surround rules are two common methods to recognize the inner area of planar graphs.
        parity rules (Odd-even rule)also known as parity rules (odd-parity rule)or even odd rules (even-odd rule),The rule draws a conceptual line (ray) from any position p to a distance away from the object's coordinate range, and counts the number of intersections along that ray with each edge. If the number of polygon edges intersecting this ray is odd, p is the internal (interior) point, otherwise p is the external (exterior) point. to get the exact number of intersecting edges, you must verify that the line you are drawing does not intersect with any polygon vertices. Figure 3.46 (a)
An example of the inner and outer regions of a set of edges that are self-intersecting based on parity rules. We can use this process for two of the same
fills the interior of a heart circle or two concentric polygons with the specified color.
another way to define an inner area is to non-0 wrapping number (nonzera winding-number) Rule. This method counts the number of times a polygon edge wraps around a particular point in a counterclockwise direction, which is called the wrapping number. Defines the interior point of a two-dimensional object as a wrapping number with a value other than 0. When you apply a non-0 wrapping rule to a polygon, the wrapping number is initialized to zero. Imagine drawing a ray from any position p to a distance away from the object's coordinate range. The selected Ray cannot intersect any vertex of the polygon. When moving from the P point along the ray direction, the direction of the edges passing through the ray is counted. each time the polygon crosses the ray from right to left, the number of edges increases by 1, and the number of edges minus 1 when left to right.. After all the crossed edges have been counted, the last value of the wrapping number determines the relative position of P. If the wrap number is nonzero, p is defined as an inner point, otherwise p is an external point. Figure 3.46 (6) shows the inner and outer regions of a self-intersecting polygon that uses a non-0 surround number rule. For simple objects such as polygons and circles, the same results are given for non-0 wrapping rules and parity rules, but for more complex shapes, the two methods may produce different internal and external areas as shown in 3.46.

       a method for determining the crossing of a forward boundaryis to create a vector (or boundary line) along the edge of the object, and the X-ray vector from p points to the cross-product operation of the edge vector E of each edge passing through the ray. Assume that there is a two-dimensional object on the XY plane, the direction of each cross product is either in the +z direction, or in the-Z direction. if the z component of the cross-product uxe is positive for a particular edge, then the edge crosses the ray from right to left, wrapping the number plus 1. Otherwise, the edges pass through the rays from left to right, and the number of wraps is reduced by 1. Edge vectors can be calculated using the end position of the edge minus the starting vertex position of the edge.
        An easier way to calculate a boundary crossing is to use dot product instead of cross product . For this purpose, a vector with a vector u orthogonal and a right-to-left direction is seen when the P-point is viewed along the U-direction. If the component of U is represented as(Ux,uy), the component of the vector perpendicular to U is (-u Y,uX). Now, if the quadrature vector is positive to the dot product of the boundary line vector, it means crossing from right to left, with the number of wraps added to 1. Otherwise, the boundary crosses the guide line from left to right, wrapping number minus 1.
       A non-0 surround number rule makes some areas internally and the parity rule makes them external, which can be useful in some applications. In general, a planar shape can be defined as a plurality of unconnected components, and the direction specified for each unconnected boundary set can be used to specify both internal and external. This example has characters (such as Arabic numerals and punctuation marks), spliced polygons, and concentric circles or ellipses. For a curve, the parity rule is applied by calculating the intersection point of the curve path. Similarly, using a non-0 surround number rule, we need to calculate the tangent vector at the intersection of the Rays from the P-point point of the curve.

transformations of a non-0 wrapping rule can be used in an internal area defined in another way . For example, we can define a point as an inner point when the wrapping number is positive or negative. We can also use any other rule to generate a variety of filled areas. Sometimes, a Boolean operation is used to specify a blend of two areas of the filled area. One way to implement Boolean operations is to use a variant of a non-0 wrapping rule. In this way, a simple disjoint boundary is defined for each region. Then, if you consider that the direction of each boundary is counterclockwise, then the two regions contain points that make the wrapping number positive (see Figure 3.47). Similarly, the intersection of two areas of the counter-clockwise boundary contains those points that make the wrapping number greater than 1, as shown in 3.48. To create a two-area differential fill area, such as a-B, we can introduce a counter-clockwise boundary of a and a clockwise boundary of B. The difference area (see figure 3.49) is the point where the wrapping number is positive.




Computer Graphics (ii) OUTPUT element _10_ Polygon filling Area _3_ Internal-external test

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.