Simple polygon

In geometry, a simple polygon /ˈpɒlɪɡɒn/ is a polygon that does not intersect itself and has no holes. That is, it is a flat shape consisting of straight, non-intersecting line segments or “sides” that are joined pairwise to form a single closed path. If the sides intersect then the polygon is not simple. The qualifier “simple” is frequently omitted, with the above definition then being understood to define a polygon in general.

The definition given above ensures the following properties:

A polygon encloses a region (called its interior) which always has a measurable area.
The line segments that make up a polygon (called sides or edges) meet only at their endpoints, called vertices (singular: vertex) or less formally “corners”.
Exactly two edges meet at each vertex.
The number of edges always equals the number of vertices.
Two edges meeting at a corner are usually required to form an angle that is not straight (180°); otherwise, the collinear line segments will be considered parts of a single side.

Mathematicians typically use “polygon” to refer only to the shape made up by the line segments, not the enclosed region, however some may use “polygon” to refer to a plane figure that is bounded by a closed path, composed of a finite sequence of straight line segments (i.e., by a closed polygonal chain). According to the definition in use, this boundary may or may not form part of the polygon itself.[1]

Simple polygons are also called Jordan polygons, because the Jordan curve theorem can be used to prove that such a polygon divides the plane into two regions, the region inside it and the region outside it. A polygon in the plane is simple if and only if it is topologically equivalent to a circle. Its interior is topologically equivalent to a disk.

在这里插入图片描述

Some simple polygons.

1 Weakly simple polygon

在这里插入图片描述
If a collection of non-crossing line segments forms the boundary of a region of the plane that is topologically equivalent to a disk, then this boundary is called a weakly simple polygon.[2] In the image on the left, ABCDEFGHJKLM is a weakly simple polygon according to this definition, with the color blue marking the region for which it is the boundary. This type of weakly simple polygon can arise in computer graphics and CAD as a computer representation of polygonal regions with holes: for each hole a “cut” is created to connect it to an external boundary. Referring to the image above, ABCM is an external boundary of a planar region with a hole FGHJ. The cut ED connects the hole with the exterior and is traversed twice in the resulting weakly simple polygonal representation.

In an alternative and more general definition of weakly simple polygons, they are the limits of sequences of simple polygons of the same combinatorial type, with the convergence under the Fréchet distance.[3] This formalizes the notion that such a polygon allows segments to touch but not to cross. However, this type of weakly simple polygon does not need to form the boundary of a region, as its “interior” can be empty. For example, referring to the image above, the polygonal chain ABCBA is a weakly simple polygon according to this definition: it may be viewed as the limit of “squeezing” of the polygon ABCFGHA.

2 Computational problems

In computational geometry, several important computational tasks involve inputs in the form of a simple polygon; in each of these problems, the distinction between the interior and exterior is crucial in the problem definition.[4]

Point in polygon testing involves determining, for a simple polygon P and a query point q, whether q lies interior to P.[5]
Simple formulae are known for computing polygon area; that is, the area of the interior of the polygon.[6]
Polygon partition is a set of primitive units (e.g. squares), which do not overlap and whose union equals the polygon. A polygon partition problem is a problem of finding a partition which is minimal in some sense, for example: a partition with a smallest number of units or with units of smallest total side-length.[7]
A special case of polygon partition is Polygon triangulation: dividing a simple polygon into triangles. Although convex polygons are easy to triangulate, triangulating a general simple polygon is more difficult because we have to avoid adding edges that cross outside the polygon. Nevertheless, Bernard Chazelle showed in 1991 that any simple polygon with n vertices can be triangulated in Θ(n) time, which is optimal. The same algorithm may also be used for determining whether a closed polygonal chain forms a simple polygon.
Another special case is the art gallery problem, which can be equivalently reformulated as a partition into a minimum number of star-shaped polygons.[7]
Boolean operations on polygons: Various Boolean operations on the sets of points defined by polygonal regions.
The convex hull of a simple polygon may be computed more efficiently than the convex hull of other types of inputs, such as the convex hull of a point set.
Voronoi diagram of a simple polygon
Medial axis/topological skeleton/straight skeleton of a simple polygon
Offset curve of a simple polygon
Minkowski sum for simple polygons

3 See also

Simple curve

OpenLayers is a popular open-source JavaScript library for displaying maps on the web. It provides various features, including the ability to create and manipulate polygons. To create a polygon using OpenLayers, you can use the `ol.geom.Polygon` class. Here's an example of how you can create a simple polygon: ```javascript // Create an array of coordinates for the polygon vertices var coordinates = [ [0, 0], [10, 0], [10, 10], [0, 10], [0, 0] ]; // Create a polygon geometry using the coordinates array var polygon = new ol.geom.Polygon([coordinates]); // Create a feature with the polygon geometry var feature = new ol.Feature(polygon); // Create a vector layer and add the feature to it var vectorLayer = new ol.layer.Vector({ source: new ol.source.Vector({ features: [feature] }) }); // Create a map and add the vector layer to it var map = new ol.Map({ target: 'map', // Specify the target HTML element layers: [vectorLayer], view: new ol.View({ center: ol.proj.fromLonLat([0, 0]), // Set the initial center of the map zoom: 2 // Set the initial zoom level }) }); ``` In this example, we create a polygon geometry using an array of coordinates representing the vertices of the polygon. We then create a feature with the polygon geometry and add it to a vector layer. Finally, we create a map and add the vector layer to display the polygon. Remember to include the OpenLayers library in your HTML file by adding the appropriate script tag: ```html <script src="https://cdn.jsdelivr.net/npm/ol@6.5.0/dist/ol.js"></script> ``` You can customize the polygon styling and add more complex functionalities based on your specific requirements.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值