Convex triangles:
A convex polygon of any n vertex can be decomposed into n-2 triangles. The geometrical knowledge indicates that the inner angle of the triangle is 180 degrees. All triangular inner angles and for (n-2) *180 degrees.
You can see that this and always equal the inner angle of the polygon and.
For a convex polygon, the inner angle is not greater than outer corner. (Outer corner not supplementary angle, a pair of inner angles outer corner and equal to 360 degrees)
Another way to detect convexity is to detect the presence of a concave point on the polygon. If one is not found, it is a convex polygon.
How to detect the turn of a point.
Cross-multiplication using edge vectors.
The normal vector of the vertex is computed using the adjacent 2 edge vectors, and then the normal vector of the polygon and the normals of the vertices are used to detect the opposite direction.
If it is negative, the vertex is a concave point.