---
title: "Polygon"
language: "en"
type: "Symbol"
summary: "Polygon[{p1, ..., pn}] represents a filled polygon with points pi. Polygon[{p1, ..., pn} -> {{q1, ..., qm}, ...}] represents a polygon with holes {q1, ..., qm}, .... Polygon[{poly1, poly2, ...}] represents a collection of polygons polyi. Polygon[{p1, ..., pn}, data] represents a polygon in which coordinates given as integers i in data are taken to be pi."
keywords: 
- 2D polygon
- 3D polygon
- face
- facet
- filled region
- polyhedra
- polyhedron
- polytope
- region
- piecewise plane
- piecewise planar
- polygonal mesh
- polygonal tiling
- polygon
- fill
- fill3
- trimesh
- triplot
- trisurf
canonical_url: "https://reference.wolfram.com/language/ref/Polygon.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Graphics Objects"
    link: "https://reference.wolfram.com/language/guide/GraphicsObjects.en.md"
  - 
    title: "Geometric Computation"
    link: "https://reference.wolfram.com/language/guide/GeometricComputation.en.md"
  - 
    title: "Maps & Cartography"
    link: "https://reference.wolfram.com/language/guide/MapsAndCartography.en.md"
  - 
    title: "Polygons"
    link: "https://reference.wolfram.com/language/guide/Polygons.en.md"
  - 
    title: "Plane Geometry"
    link: "https://reference.wolfram.com/language/guide/PlaneGeometry.en.md"
  - 
    title: "Basic Geometric Regions"
    link: "https://reference.wolfram.com/language/guide/GeometricSpecialRegions.en.md"
  - 
    title: "Precollege Education"
    link: "https://reference.wolfram.com/language/guide/PrecollegeEducation.en.md"
  - 
    title: "Solid Geometry"
    link: "https://reference.wolfram.com/language/guide/SolidGeometry.en.md"
  - 
    title: "Synthetic Geometry"
    link: "https://reference.wolfram.com/language/guide/SyntheticGeometry.en.md"
  - 
    title: "Symbolic Graphics Language"
    link: "https://reference.wolfram.com/language/guide/SymbolicGraphicsLanguage.en.md"
related_functions: 
  - 
    title: "PolygonCoordinates"
    link: "https://reference.wolfram.com/language/ref/PolygonCoordinates.en.md"
  - 
    title: "OuterPolygon"
    link: "https://reference.wolfram.com/language/ref/OuterPolygon.en.md"
  - 
    title: "InnerPolygon"
    link: "https://reference.wolfram.com/language/ref/InnerPolygon.en.md"
  - 
    title: "Triangle"
    link: "https://reference.wolfram.com/language/ref/Triangle.en.md"
  - 
    title: "Rectangle"
    link: "https://reference.wolfram.com/language/ref/Rectangle.en.md"
  - 
    title: "Parallelogram"
    link: "https://reference.wolfram.com/language/ref/Parallelogram.en.md"
  - 
    title: "RegularPolygon"
    link: "https://reference.wolfram.com/language/ref/RegularPolygon.en.md"
  - 
    title: "Simplex"
    link: "https://reference.wolfram.com/language/ref/Simplex.en.md"
  - 
    title: "CrossingPolygon"
    link: "https://reference.wolfram.com/language/ref/CrossingPolygon.en.md"
  - 
    title: "WindingPolygon"
    link: "https://reference.wolfram.com/language/ref/WindingPolygon.en.md"
  - 
    title: "CanonicalizePolygon"
    link: "https://reference.wolfram.com/language/ref/CanonicalizePolygon.en.md"
  - 
    title: "RandomPolygon"
    link: "https://reference.wolfram.com/language/ref/RandomPolygon.en.md"
  - 
    title: "MeshRegion"
    link: "https://reference.wolfram.com/language/ref/MeshRegion.en.md"
  - 
    title: "GeometricScene"
    link: "https://reference.wolfram.com/language/ref/GeometricScene.en.md"
related_tutorials: 
  - 
    title: "Three-Dimensional Graphics Primitives"
    link: "https://reference.wolfram.com/language/tutorial/TheStructureOfGraphicsAndSound.en.md#32364"
  - 
    title: "Three-Dimensional Graphics Directives"
    link: "https://reference.wolfram.com/language/tutorial/TheStructureOfGraphicsAndSound.en.md#11149"
  - 
    title: "The Structure of Graphics"
    link: "https://reference.wolfram.com/language/tutorial/TheStructureOfGraphicsAndSound.en.md#11957"
---
# Polygon

Polygon[{p1, …, pn}] represents a filled polygon with points pi.

Polygon[{p1, …, pn} -> {{q1, …, qm}, …}] represents a polygon with holes {q1, …, qm}, ….

Polygon[{poly1, poly2, …}] represents a collection of polygons polyi.

Polygon[{p1, …, pn}, data] represents a polygon in which coordinates given as integers i in data are taken to be pi.

## Details and Options

* ``Polygon`` can be used as a geometric region and a graphics primitive.

* ``Polygon[{p1, …, pn}]`` is a plane region, representing all the points inside the closed curve with line segments ``{p1, p2}, …, {pn - 1, pn}`` and ``{pn, p1}``.

* A point is an element of the polygon if a ray from the point in any direction in the plane crosses the boundary line segments an odd number of times.

[image]

* ``Polygon[{p1, …, pn} -> {{q1, …, qm}, …}]`` specifies a polygon with holes consisting of an outer polygon ``Polygon[{p1, …, pn}]`` and one or several inner polygons ``Polygon[{q1, …, qm}], …``.

* A point is an element of the polygon if it is in the outer polygon but not in any inner polygon.

[image]

* ``Polygon[{poly1, poly2, …}]`` is a collection of polygons ``polyi`` with or without holes and is treated as a union of ``polyi`` for geometric computations.

[image]

* ``Polygon[{p1, …, pn}, data]`` effectively replaces integers ``i`` that appear as coordinates in ``data`` by the corresponding ``pi``.

|                                                                        |                                                                                           |
| ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| Polygon[{p1, …, pn}, {b1, …, bn}]                                      | polygon boundary points {pb1, …, pbk}                                                     |
| Polygon[{p1, …, pn}, {{o1, …, ok} -> {{i1, …, il}, …}]                  | outer polygon boundary points {po1, …, pok} and inner polygon boundary {pi1, …, pil} etc. |
| Polygon[{p1, …, pn}, {{b1, …, bn}, {o1, …, ok} -> {{i1, …, il}, …}, …}] | a collection of several polygons                                                          |

* As a geometric region, the points ``pi`` can have any embedding dimension, but must all lie in a plane and have the same embedding dimension.

* In a graphic, the points ``pi`` can be ``Scaled``, ``Offset``, ``ImageScaled`` and ``Dynamic`` expressions.

* Graphics rendering is affected by directives such as ``FaceForm``, ``EdgeForm``, ``Texture``, ``Specularity``, ``Opacity`` and color.

* ``FaceForm[front, back]`` can be used to specify different styles for the front and back of polygons in 3D. The front is defined by the right-hand rule and the direction of the first three points.

* The following options and settings can be used in graphics:

|                           |           |                                      |
| ------------------------- | --------- | ------------------------------------ |
| VertexColors              | Automatic | vertex colors to be interpolated     |
| VertexNormals             | Automatic | effective vertex normals for shading |
| VertexTextureCoordinates  | None      | coordinates for textures             |

* ``Polygon`` can be used with symbolic points in ``GeometricScene``.

---

## Examples (43)

### Basic Examples (2)

A polygon:

```wl
In[1]:= pol = Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}]

Out[1]= Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}]
```

Its graphic image:

```wl
In[2]:= Graphics[pol]

Out[2]= [image]
```

Its area:

```wl
In[3]:= Area[pol]

Out[3]= Sqrt[3]
```

---

Differently styled 3D polygons:

```wl
In[1]:= pol = Polygon[{{1, 0, 0}, {1, 1, 1}, {0, 0, 1}}];

In[2]:= {Graphics3D[{Pink, pol}], Graphics3D[{EdgeForm[Thick], Pink, pol}], Graphics3D[{EdgeForm[Dashed], Pink, pol}]}

Out[2]= {[image], [image], [image]}
```

### Scope (21)

#### Graphics (11)

##### Specification (2)

A collection of polygons:

```wl
In[1]:= p2 = {{0, 0}, {1, 0}, {0, 1}};

In[2]:= Graphics[Polygon[{p2, p2 + 1}]]

Out[2]= [image]

In[3]:= p3 = {{1, 0, 0}, {1, 1, 1}, {0, 0, 1}};

In[4]:= Graphics3D[Polygon[{p3, p3 + 1}]]

Out[4]= [image]
```

---

Polygons with multiple vertices:

```wl
In[1]:= Graphics[Polygon[Table[{Cos[2π k / 6], Sin[2π k / 6]}, {k, 0, 5}]]]

Out[1]= [image]

In[2]:= Graphics3D[Polygon[Table[{Cos[2π k / 6], Sin[2π k / 6], 0}, {k, 0, 5}]]]

Out[2]= [image]
```

##### Styling (6)

Color directives specify the face colors of polygons:

```wl
In[1]:= Table[Graphics[{c, Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}]}], {c, {Red, Green, Blue, Yellow}}]

Out[1]= {[image], [image], [image], [image]}

In[2]:= Table[Graphics3D[{c, Polygon[{{1, 0, 0}, {1, 1, 1}, {0, 0, 1}}]}], {c, {Red, Green, Blue, Yellow}}]

Out[2]= {[image], [image], [image], [image]}
```

---

``Texture`` can be used to specify a texture to be used on the faces of polygons:

```wl
In[1]:= {Graphics[{Texture[ExampleData[{"TestImage", "JellyBeans2"}]], Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}, VertexTextureCoordinates -> {{1, 0}, {0.5, 1}, {0, 0}}]}], Graphics3D[{Texture[ExampleData[{"TestImage", "JellyBeans2"}]], Polygon[{{0, 0, 0}, {1, 1, 0}, {0, 1, 1}}, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {0.5, 1}}]}, Lighting -> "Neutral"]}

Out[1]= [image]
```

``Texture`` can work together with different ``Opacity`` :

```wl
In[2]:= Table[Graphics[{Opacity[o], Texture[ExampleData[{"TestImage", "House"}]], Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}, VertexTextureCoordinates -> {{1, 0}, {0.5, 1}, {0, 0}}]}], {o, {0.25, 0.5, 0.75, 1}}]

Out[2]= [image]
```

``Texture`` can work together with different ``Lighting`` :

```wl
In[3]:= Table[Graphics3D[{Texture[ExampleData[{"TestImage", "Sailboat"}]], Polygon[{{0, 0, 0}, {1, 1, 0}, {0, 1, 1}}, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {0.5, 1}}]}, Lighting -> {{"Directional", c, {4, -4, 4}}}], {c, {Red, Green, Yellow, White}}]

Out[3]= [image]
```

---

``FaceForm`` and ``EdgeForm`` can be used to specify the styles of the interiors and boundaries:

```wl
In[1]:= Graphics[{FaceForm[Pink], EdgeForm[Directive[Dashed, Thick, Blue]], Polygon[{{0, 0}, {0, 1}, {1, 1}, {1, 0}}]}]

Out[1]= [image]

In[2]:= Graphics3D[{FaceForm[Pink], EdgeForm[Directive[Dashed, Thick, Blue]], Polygon[{{0, 0, 0}, {1, 1, 0}, {1, 1, 1}, {0, 0, 1}}]}]

Out[2]= [image]
```

---

In 3D, different properties can be specified for the front and back of faces using ``FaceForm`` :

```wl
In[1]:= p = {FaceForm[Yellow, Blue], Polygon[{{1, 0, 0}, {0, Sqrt[3], 0}, {-1, 0, 0}}]};

In[2]:= {Graphics3D[p, ViewPoint -> Top], Graphics3D[p, ViewPoint -> Bottom]}

Out[2]= {[image], [image]}
```

Use ``FaceForm`` to set front and back textures differently in 3D:

```wl
In[3]:=
vtc = {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
coords = {{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}}, {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}}, {{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}}, {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}}};

In[4]:= Graphics3D[{FaceForm[Texture[[image]], Texture[[image]]], Polygon[coords, VertexTextureCoordinates -> Table[vtc, {6}]]}, Lighting -> "Neutral"]

Out[4]= [image]
```

---

Colors can be specified at vertices using ``VertexColors`` :

```wl
In[1]:= Graphics[Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}, VertexColors -> {Red, Green, Blue}]]

Out[1]= [image]

In[2]:= Graphics3D[Polygon[{{1, 0, 0}, {1, 1, 1}, {0, 0, 1}}, VertexColors -> {Red, Green, Blue}]]

Out[2]= [image]
```

---

Normals can be specified at vertices using ``VertexNormals`` for 3D polygons:

```wl
In[1]:= n = {1, -1, 1};

In[2]:= Graphics3D[{Yellow, Polygon[{{1, 0, 0}, {1, 1, 1}, {0, 0, 1}}, VertexNormals -> {-n, n, n}]}]

Out[2]= [image]
```

##### Coordinates (3)

Use ``Scaled`` coordinates:

```wl
In[1]:= Graphics[Polygon[{Scaled[{0, 0}], Scaled[{.5, 1}], Scaled[{1, 0}]}], Frame -> True]

Out[1]= [image]

In[2]:= Graphics3D[Polygon[{Scaled[{0, 0, .2}], Scaled[{.5, 1, .8}], Scaled[{1, 0, .2}]}], Axes -> True]

Out[2]= [image]
```

---

Use ``ImageScaled`` coordinates in 2D:

```wl
In[1]:= Graphics[Polygon[{ImageScaled[{0, 0}], ImageScaled[{.5, 1}], ImageScaled[{1, 0}]}], Frame -> True]

Out[1]= [image]
```

---

Use ``Offset`` coordinates in 2D:

```wl
In[1]:= Graphics[Polygon[{Offset[{10, 10}, {0, 0}], Offset[{0, -20}, {.5, 1}], Offset[{-10, 10}, {1, 0}]}], Frame -> True]

Out[1]= [image]
```

#### Regions (10)

Embedding dimension:

```wl
In[1]:= RegionEmbeddingDimension[Polygon[{{1, 0, 0}, {1, 1, 1}, {0, 0, 1}}]]

Out[1]= 3
```

Geometric dimension:

```wl
In[2]:= RegionDimension[Polygon[{{1, 0, 0}, {1, 1, 1}, {0, 0, 1}}]]

Out[2]= 2
```

---

Point membership test:

```wl
In[1]:= ℛ = Polygon[{{1, 0, 0}, {1, 1, 1}, {0, 0, 1}}];

In[2]:= {RegionMember[ℛ, {2 / 3, 1 / 3, 2 / 3}], RegionMember[ℛ, {0, 0, 0}]}

Out[2]= {True, False}
```

Get conditions for point membership:

```wl
In[3]:= RegionMember[ℛ, {x, y, z}]

Out[3]= (x | y | z)∈ℝ && -1 + x - y + z == 0 && y ≥ 0 && 1 - x ≥ 0 && 1 - x + y ≤ 1
```

---

Area:

```wl
In[1]:= ℛ = Polygon[{{1, 0}, {1, 1}, {0, 0}}];

In[2]:= {Area[ℛ], RegionMeasure[ℛ]}

Out[2]= {(1/2), (1/2)}
```

Centroid:

```wl
In[3]:= c = RegionCentroid[ℛ]

Out[3]= {(2/3), (1/3)}

In[4]:= Graphics[{{Pink, ℛ}, {Black, Point[c]}}]

Out[4]= [image]
```

---

Distance from a point:

```wl
In[1]:= ℛ = Polygon[{{-2, 0}, {-1, 3 / 2}, {1, 3 / 2}, {2, 0}, {1, -3 / 2}, {-1, -3 / 2}}];

In[2]:= {RegionDistance[ℛ, {3, 4}], RegionDistance[ℛ, {1, 1}]}

Out[2]= {(Sqrt[41]/2), 0}
```

Plot it:

```wl
In[3]:= {Plot3D[Evaluate@RegionDistance[ℛ, {x, y}], {x, -3, 3}, {y, -3, 3}, MeshFunctions -> {#3&}, Mesh -> 5], ContourPlot[Evaluate@RegionDistance[ℛ, {x, y}], {x, -4, 4}, {y, -4, 4}, Contours -> {{0.5, Red}, {1, Green}, {1.5, Blue}}]}

Out[3]= [image]
```

---

Signed distance from a point:

```wl
In[1]:= ℛ = Polygon[{{-2, 0}, {-1, 3 / 2}, {1, 3 / 2}, {2, 0}, {1, -3 / 2}, {-1, -3 / 2}}];

In[2]:= {SignedRegionDistance[ℛ, {3, 4}], SignedRegionDistance[ℛ, {1, 1}]}

Out[2]= {(Sqrt[41]/2), -(1/Sqrt[13])}
```

Plot it:

```wl
In[3]:= Plot3D[SignedRegionDistance[ℛ, {x, y}], {x, -3, 3}, {y, -3, 3}, MeshFunctions -> {#3&}, Mesh -> {{0}}, MeshShading -> {Red, Green}]

Out[3]= [image]
```

---

Nearest point in the region:

```wl
In[1]:= ℛ = Polygon[{{-2, 0}, {-1, 3 / 2}, {1, 3 / 2}, {2, 0}, {1, -3 / 2}, {-1, -3 / 2}}];

In[2]:= RegionNearest[ℛ, {3, 4}]

Out[2]= {1, (3/2)}
```

Nearest points:

```wl
In[3]:=
pts = Table[4{Cos[k 2 π / 25], Sin[k 2π / 25]}, {k, 0., 24}];
nst = RegionNearest[ℛ, #]& /@ pts;

In[4]:= Legended[Graphics[{{Gray, ℛ}, {Thin, Gray, Line[Transpose[{pts, nst}]]}, {Red, Point[pts]}, {Blue, Point[nst]}}], PointLegend[{Red, Blue}, {"start", "nearest"}]]

Out[4]= [image]
```

---

A polygon is bounded:

```wl
In[1]:= ℛ = Polygon[{{-2, 0}, {-1, 3 / 2}, {1, 3 / 2}, {2, 0}, {1, -3 / 2}, {-1, -3 / 2}}];

In[2]:= BoundedRegionQ[ℛ]

Out[2]= True
```

Get its range:

```wl
In[3]:= rr = RegionBounds[ℛ]

Out[3]= {{-2, 2}, {-(3/2), (3/2)}}

In[4]:= Graphics[{ℛ, {EdgeForm[{Dashed, Red}], Opacity[0.2, Yellow], Cuboid@@Transpose[rr]}}]

Out[4]= [image]
```

---

``Integrate`` over a polygon:

```wl
In[1]:= ℛ = Polygon[{{-2, 0}, {-1, 3 / 2}, {1, 3 / 2}, {2, 0}, {1, -3 / 2}, {-1, -3 / 2}}];

In[2]:= Integrate[x ^ 2 + y ^ 2, {x, y}∈ℛ]

Out[2]= (105/8)
```

---

Optimize over a polygon:

```wl
In[1]:= ℛ = Polygon[{{-2, 0}, {-1, 3 / 2}, {1, 3 / 2}, {2, 0}, {1, -3 / 2}, {-1, -3 / 2}}];

In[2]:= Minimize[{x y - x, {x, y}∈ℛ}, {x, y}]

Out[2]= {-(8/3), {x -> (4/3), y -> -1}}
```

---

Solve equations in a polygon:

```wl
In[1]:= ℛ = Polygon[{{-2, 0}, {-1, 3 / 2}, {1, 3 / 2}, {2, 0}, {1, -3 / 2}, {-1, -3 / 2}}];

In[2]:= Solve[x^2 + y^2 == 4 && {x, y}∈ℛ, {x, y}]

Out[2]= {{x -> -2, y -> 0}, {x -> 2, y -> 0}}

In[3]:= Graphics[{{LightBlue, EdgeForm[Gray], ℛ}, {Black, Circle[{0, 0}, 2]}, {Red, PointSize[Medium], Point[{x, y} /. %]}}]

Out[3]= [image]
```

### Options (7)

#### VertexColors (2)

Polygon with vertex colors:

```wl
In[1]:= Graphics[Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}, VertexColors -> {Red, Green, Blue}]]

Out[1]= [image]
```

---

Specify vertex colors for 3D polygons:

```wl
In[1]:= Graphics3D[Polygon[{{1, 0, 0}, {1, 1, 1}, {0, 0, 1}}, VertexColors -> {Red, Green, Blue}]]

Out[1]= [image]
```

#### VertexNormals (1)

Compute normal vectors using the cross product of edge vectors:

```wl
In[1]:= {p1, p2, p3} = {{1, 0, 0}, {1, 1, 1}, {0, 0, 1}};

In[2]:= n = Cross[p2 - p1, p3 - p1]

Out[2]= {1, -1, 1}
```

A triangle with normals pointing in the direction ``{1, -1, 1}`` :

```wl
In[3]:= Graphics3D[{Yellow, Polygon[{p1, p2, p3}, VertexNormals -> {n, n, n}]}]

Out[3]= [image]
```

Using different normals will affect shading:

```wl
In[4]:= Graphics3D[{Yellow, Polygon[{p1, p2, p3}, VertexNormals -> {-n, n, n}]}]

Out[4]= [image]
```

#### VertexTextureCoordinates (4)

Texture-mapped polygon:

```wl
In[1]:= Graphics[{Texture[ExampleData[{"TestImage", "Flower"}]], Polygon[{{1, 0}, {0, Sqrt[3]}, {-1, 0}}, VertexTextureCoordinates -> {{1, 0}, {0.5, 1}, {0, 0}}]}]

Out[1]= [image]
```

---

Texture mapping with 2D polygons:

```wl
In[1]:= Graphics[{Texture[ExampleData[{"TestImage", "Airplane2"}]], Polygon[{{1, 1}, {3, 1}, {3, 3}, {1, 3}}, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}]

Out[1]= [image]
```

Texture mapping with 3D polygons:

```wl
In[2]:= Graphics3D[{Texture[ExampleData[{"TestImage", "Airplane2"}]], Polygon[{{-1, -1, 0}, {1, -1, 0}, {1, 1, 0}, {-1, 1, 0}}, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]}, Lighting -> "Neutral"]

Out[2]= [image]
```

---

Repeat a texture by using non-unified texture coordinate values:

```wl
In[1]:= {Graphics[{Texture[ExampleData[{"TestImage", "Mandrill"}]], Polygon[{{1, 1}, {3, 1}, {3, 3}, {1, 3}}, VertexTextureCoordinates -> {{0, 0}, {2, 0}, {2, 2}, {0, 2}}]}], Graphics3D[{Texture[ExampleData[{"TestImage", "Mandrill"}]], Polygon[{{-1, -1, 0}, {1, -1, 0}, {1, 1, 0}, {-1, 1, 0}}, VertexTextureCoordinates -> {{0, 0}, {2, 0}, {2, 2}, {0, 2}}]}, Lighting -> "Neutral"]}

Out[1]= [image]
```

---

Texture mapping is preceded by ``VertexColors`` :

```wl
In[1]:=
Graphics3D[{Texture[[image]], Polygon[{{-1, -1, -1}, {1, -1, -1}, {1, 1, -1}, {-1, 1, -1}}, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}, 
	VertexColors -> {Red, Green, Blue, Purple}]}, Lighting -> "Neutral"]

Out[1]= [image]
```

### Applications (3)

Define a polygon with $n$ vertices:

```wl
In[1]:= ngon[p_, q_] := Polygon[Table[{Cos[2Pi k q / p], Sin[2Pi k q / p]}, {k, p}]]
```

Regular polygons:

```wl
In[2]:= Row[Table[Graphics[{EdgeForm[Black], LightRed, ngon[n, 1]}, ImageSize -> 70], {n, 3, 14}]]

Out[2]= [image][image][image][image][image][image][image][image][image][image][image][image]
```

Star polygons:

```wl
In[3]:= Row[Reap[Table[Table[If[CoprimeQ[p, q], Sow[Graphics[{EdgeForm[Black], LightGreen, ngon[p, q]}, ImageSize -> 70]]], {q, 2, p / 2}], {p, 5, 12}]][[2, 1]]]

Out[3]= [image][image][image][image][image][image][image][image][image][image][image][image]
```

---

Define the regular hexagon:

```wl
In[1]:= h[x_, y_] := Polygon[Table[{Cos[2Pi k / 6] + x, Sin[2Pi k / 6] + y}, {k, 6}]]
```

Regular hexagonal tiling:

```wl
In[2]:= Graphics[{EdgeForm[Opacity[.7]], LightBlue, Table[h[3i + 3((-1) ^ j + 1) / 4, Sqrt[3] / 2j], {i, 5}, {j, 10}]}]

Out[2]= [image]
```

---

Get face polygons from ``PolyhedronData`` :

```wl
In[1]:= p = N[PolyhedronData["TruncatedIcosahedron", "Faces", "Polygon"]];
```

Shrink each face with respect to the centroid:

```wl
In[2]:= shrink[t_, Polygon[x_List, opts___]] := Module[{c = Plus@@x / Length[x]}, Polygon[Map[(c + (1 - t)(# - c))&, x], opts]]

In[3]:= Animate[Graphics3D[{FaceForm[Yellow, Green], p /. y_Polygon :> shrink[s, y]}, PlotRange -> 2.5], {s, 0, .8}, SaveDefinitions -> True, AnimationRunning -> False, AnimationDirection -> ForwardBackward, DefaultDuration -> 1]

Out[3]= DynamicModule[«9»]
```

### Properties & Relations (4)

``GraphicsComplex`` offers an efficient way to generate a polygon with many shared vertices:

```wl
In[1]:= v = {{0, 0, 0}, {2, 0, 0}, {2, 2, 0}, {0, 2, 0}, {1, 1, 2}};

In[2]:= i = {{1, 2, 5}, {2, 3, 5}, {3, 4, 5}, {4, 1, 5}};

In[3]:= {Graphics3D[{Opacity[.7], GraphicsComplex[v, Polygon[i]]}], Graphics3D[{GraphicsComplex[v, Line[i]]}]}

Out[3]= {[image], [image]}
```

Applying ``Normal`` to the graphics complex produces ordinary polygons:

```wl
In[4]:= Normal[GraphicsComplex[v, Polygon[i]]]

Out[4]= {{Polygon[{{0, 0, 0}, {2, 0, 0}, {1, 1, 2}}], Polygon[{{2, 0, 0}, {2, 2, 0}, {1, 1, 2}}], Polygon[{{2, 2, 0}, {0, 2, 0}, {1, 1, 2}}], Polygon[{{0, 2, 0}, {0, 0, 0}, {1, 1, 2}}]}}
```

---

``Polygon`` is a generalization of ``Triangle`` :

```wl
In[1]:=
Subscript[ℛ, 1] = Polygon[{{0, 0}, {1, 0}, {1, 1}}];
Subscript[ℛ, 2] = Triangle[{{0, 0}, {1, 0}, {1, 1}}];

In[2]:= RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]

Out[2]= True
```

---

``Polygon`` is a generalization of ``Rectangle`` :

```wl
In[1]:=
Subscript[ℛ, 1] = Polygon[{{0, 0}, {1, 0}, {1, 1}, {0, 1}}];
Subscript[ℛ, 2] = Rectangle[{0, 0}, {1, 1}];

In[2]:= RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]

Out[2]= True
```

---

A ``Simplex`` with three vertices is a special case of ``Polygon`` :

```wl
In[1]:=
Subscript[ℛ, 1] = Polygon[{{0, 0}, {1, 0}, {1, 1}}];
Subscript[ℛ, 2] = Simplex[{{0, 0}, {1, 0}, {1, 1}}];

In[2]:= RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]

Out[2]= True
```

In any number of dimensions starting from 2:

```wl
In[3]:=
Subscript[ℛ, 1] = Polygon[{{0, 0, 0}, {1, 0, 0}, {1, 1, 0}}];
Subscript[ℛ, 2] = Simplex[{{0, 0, 0}, {1, 0, 0}, {1, 1, 0}}];

In[4]:= RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]

Out[4]= True
```

### Possible Issues (3)

In 3D, if the vertices are not in a plane, the polygon triangulation can be unpredictable:

```wl
In[1]:= Graphics3D[Polygon[{{0, 0, 0}, {1, 1, 0}, {0, 1, 0}, {0, 0, 1}}]]

Out[1]= [image]

In[2]:= Graphics3D[Polygon[RandomReal[1, {10, 3}]]]

Out[2]= [image]
```

---

Degenerate polygons are not valid geometric regions:

```wl
In[1]:= Polygon[{{0, 0, 0}, {1, 1, 0}, {0, 1, 0}, {0, 0, 1}}]

Out[1]= Polygon[{{0, 0, 0}, {1, 1, 0}, {0, 1, 0}, {0, 0, 1}}]

In[2]:= RegionQ[%]

Out[2]= False
```

---

Seams can sometimes appear between individual polygons as a result of antialiasing:

```wl
In[1]:= Graphics[{Gray, Table[Polygon[{{x, 0}, {x + 1, 0}, {x + 1, 1}, {x, 1}}], {x, 0, 2}]}]

Out[1]= [image]
```

Using a single polygon object avoids any seams:

```wl
In[2]:= Graphics[{Gray, Polygon[Table[{{x, 0}, {x + 1, 0}, {x + 1, 1}, {x, 1}}, {x, 0, 2}]]}]

Out[2]= [image]
```

### Neat Examples (3)

Random triangle collections:

```wl
In[1]:= Graphics[Table[{EdgeForm[Black], Hue[RandomReal[]], Polygon[RandomReal[1, {3, 2}]]}, {30}]]

Out[1]= [image]

In[2]:= Graphics3D[Table[{EdgeForm[Black], Opacity[.7], Hue[RandomReal[]], Polygon[RandomReal[1, {3, 3}]]}, {30}], Lighting -> "Neutral"]

Out[2]= [image]
```

---

Digital petals:

```wl
In[1]:= With[{d = 2Pi / 12}, Graphics[Table[{EdgeForm[Opacity[.6]], Hue[(-11 + q + 10 r) / 72], Polygon[{(8 - r){Cos[d(q - 1)], Sin[d(q - 1)]}, (8 - r){Cos[d(q + 1)], Sin[d(q + 1)]}, (10 - r){Cos[d q], Sin[d q]}}]}, {r, 6}, {q, 12}]]]

Out[1]= [image]
```

---

A rotating star:

```wl
In[1]:= Animate[Graphics[Rotate[Polygon[Table[{Cos[t], Sin[t]}, {t, 0, 4Pi, 4Pi / 5}]], θ, {0, 0}], PlotRange -> 1.2], {θ, 0, 2π}, AnimationRunning -> False]

Out[1]= DynamicModule[«7»]
```

## See Also

* [`PolygonCoordinates`](https://reference.wolfram.com/language/ref/PolygonCoordinates.en.md)
* [`OuterPolygon`](https://reference.wolfram.com/language/ref/OuterPolygon.en.md)
* [`InnerPolygon`](https://reference.wolfram.com/language/ref/InnerPolygon.en.md)
* [`Triangle`](https://reference.wolfram.com/language/ref/Triangle.en.md)
* [`Rectangle`](https://reference.wolfram.com/language/ref/Rectangle.en.md)
* [`Parallelogram`](https://reference.wolfram.com/language/ref/Parallelogram.en.md)
* [`RegularPolygon`](https://reference.wolfram.com/language/ref/RegularPolygon.en.md)
* [`Simplex`](https://reference.wolfram.com/language/ref/Simplex.en.md)
* [`CrossingPolygon`](https://reference.wolfram.com/language/ref/CrossingPolygon.en.md)
* [`WindingPolygon`](https://reference.wolfram.com/language/ref/WindingPolygon.en.md)
* [`CanonicalizePolygon`](https://reference.wolfram.com/language/ref/CanonicalizePolygon.en.md)
* [`RandomPolygon`](https://reference.wolfram.com/language/ref/RandomPolygon.en.md)
* [`MeshRegion`](https://reference.wolfram.com/language/ref/MeshRegion.en.md)
* [`GeometricScene`](https://reference.wolfram.com/language/ref/GeometricScene.en.md)

## Tech Notes

* [Three-Dimensional Graphics Primitives](https://reference.wolfram.com/language/tutorial/TheStructureOfGraphicsAndSound.en.md#32364)
* [Three-Dimensional Graphics Directives](https://reference.wolfram.com/language/tutorial/TheStructureOfGraphicsAndSound.en.md#11149)
* [The Structure of Graphics](https://reference.wolfram.com/language/tutorial/TheStructureOfGraphicsAndSound.en.md#11957)

## Related Guides

* [Graphics Objects](https://reference.wolfram.com/language/guide/GraphicsObjects.en.md)
* [Geometric Computation](https://reference.wolfram.com/language/guide/GeometricComputation.en.md)
* [Maps & Cartography](https://reference.wolfram.com/language/guide/MapsAndCartography.en.md)
* [`Polygons`](https://reference.wolfram.com/language/guide/Polygons.en.md)
* [Plane Geometry](https://reference.wolfram.com/language/guide/PlaneGeometry.en.md)
* [Basic Geometric Regions](https://reference.wolfram.com/language/guide/GeometricSpecialRegions.en.md)
* [Precollege Education](https://reference.wolfram.com/language/guide/PrecollegeEducation.en.md)
* [Solid Geometry](https://reference.wolfram.com/language/guide/SolidGeometry.en.md)
* [Synthetic Geometry](https://reference.wolfram.com/language/guide/SyntheticGeometry.en.md)
* [Symbolic Graphics Language](https://reference.wolfram.com/language/guide/SymbolicGraphicsLanguage.en.md)

## Related Links

* [An Elementary Introduction to the Wolfram Language: Coordinates and Graphics](https://www.wolfram.com/language/elementary-introduction/14-coordinates-and-graphics.html)

## History

* Introduced in 1988 (1.0) \| Updated in 1996 (3.0) ▪ [2019 (12.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn120.en.md)