Method for Determining Convex Polygon
In the calculation of geometric and geographic information systems, it is very important to determine the convex and convex aspects of polygon. So what are concave polygon and convex polygon? First, we can intuitively understand that a convex polygon is the link between any two vertices of a polygon within the polygon, so the concave polygon can at least find a line out of the polygon.
Basic Concepts
Vertex, vector, vector cross multiplication,
Generally, a polygon is composed of vertices connected at the beginning and end. The vertex here is the point in the ry. In 2D and 3D ry, vertices and vectors can be expressed by a class or struct, but there is a fundamental difference between vertices and vectors in mathematics. A vertex has a position but no direction. The vector has no position, but has a direction, mainly to express the displacement in the ry.
In polygon concave and convex judgment, vector cross multiplication is used, that is, vector cross multiplication. Vector cross-multiplication is very important in graphics systems, including CAD and geographic information systems.
Several common methods for determining Convex Polygon:
1) angle method:
Determine whether the inner angle of each vertex is less than 180 degrees. If it is less than 180 degrees, it is convex. If it is greater than 180 degrees, it is a concave polygon.
2) Convex Hull method:
This method first calculates the convex hull of the polygon. The definition of the convex hull is not described here. First of all, it is certain that the convex hull must be a convex polygon. If the calculated convex polygon has the same number of points as the original polygon, it indicates that this polygon is convex polygon, otherwise it is a concave polygon.
3) vertex concave/convex Method
Use the vector cross-multiplication centered on the current vertex or calculate the signed area of the triangle to determine the direction of the polygon and the concave and convex properties of the current vertex.
Assume that the three consecutive vertices are P1, P2, and P3. The calculated vector P1P2 and p2p3 cross Multiplication can also calculate the area of the triangle p1p2p3. If the obtained result is greater than 0, it indicates the left side of the online segments P1 and P2 of P3, the vertex of a polygon is a counter-clockwise sequence. Then calculate the cross multiplication of the next front and back vectors in sequence. If a negative value occurs during calculation, the concave polygon is used for this polygon. If all vertices are calculated, the result is greater than 0, the polygon is convex.
4) Area Method of Simpson
Use the vertex to be identified and the triangle composed of the first and second vertices to calculate the area using the Simpson formula. If the area of the triangle is the same as the area symbol of the whole polygon, the vertex is convex; if the area of the triangle is different from that of the whole polygon, the vertex is concave, that is, the whole polygon is also a concave polygon.
Conclusion: The above are only several basic determination methods. Of course, there are still better algorithms. This is the end of my personal ability.