Computer Graphics (ii) OUTPUT element _10_ polygon filling area _2_ segmented concave polygon

Source: Internet
Author: User

Split Concave polygon

Once the concave polygon is identified, we can cut it into a set of convex polygons. This can be done using the edge vector and the edge cross product. We can use the relationship of vertex and edge extension lines to determine which vertices are on one side and which vertices are on the other side. In the following algorithm we assume that all polygons are on the XY plane. Of course, the initial position of the polygons described in the world coordinate system may not be on the XY plane, but we can use the transformation method discussed in chapter 5th to move them to the XY plane. For vector methodsthat divide concave polygons, we first have to form edge vectors. Given successive vector positions VK and vk+1 define the edge vectors:

Then, the cross product of continuous edge vectors is calculated by polygon boundary order. if some of the cross product's Z component is positive while others are negative, the polygon is concave, otherwise the polygon is a convex polygon. This means that there is no three consecutive vertex collinear, i.e. there is no continuous two edge vectors with a cross product of 0. If all vertices are collinear, a degenerate polygon (a segment) is obtained. We can apply the vector method by processing the edge vectors in a counterclockwise direction. If there is a negative Z component of the cross product (3.43), then the polygon is concave and can be cut along the line of the first-side vector in the cross product. The following example shows this method of dividing concave polygons.

Example 3.4 vector method for dividing concave polygons

Figure 3.44 shows a concave polygon with 6 vertices. The edge vector of the polygon is expressed as

The Z-Components Here are all 0 because all edges are on the XY plane . The cross product of two consecutive edge vectors ejx ek is a vector perpendicular to the XY plane, and its components are ejxeky-ekxejy:

Because the z-component of the E2 x E3 is negative, we divide the polygons along the lines of the vector E2 . The slope in the line equation for the edge is 1 and the Y-intercept is-1. Then we can determine the intersection of this line and the other edges to split the polygon into two pieces. The other side of the product is not negative, so the resulting two polygons are convex polygons.

We can also use the rotational method to split concave polygons. moves the vertex VK to the coordinate system origin in a counterclockwise direction along the edges of the polygon. Then rotate the polygon clockwise so that the next vertex vk+1 on the x-axis. If the next vertex vk+2 is below the x-axis, the polygon is concave. We then use the x-axis to split the polygon into two new polygons and re-use the concave test for these two new polygons. The above steps are repeated until all vertices in the polygon have been tested. The method of rotating and moving the object position is discussed in Chapter 5th. Figure 3.45 shows the rotation method of the segmented concave polygon.


Dividing a convex polygon into a triangular set

Once you have a set of vertices for a convex polygon, we can turn it into a set of triangles . This is done by defining three consecutive vertices in any order as a new polygon (triangle). The middle vertex of the triangle is then removed from the polygon's original vertex queue. The modified vertex queue is then processed using the same procedure to separate the other triangles. This split continues until the original polygon leaves only three vertices, which define the last one in the triangle set. Concave polygons can also be split into triangle sets using this method, but require each three vertices to form an inner angle less than 180o (a "convex" angle).

Computer Graphics (ii) OUTPUT element _10_ polygon filling area _2_ segmented concave polygon

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.