# PolygonGeometry

> The geometry of a closed convex polygon. The geometry has a fixed maximum number of vertices as defined by the constant PhysicsConstants.MaxPolygonVertices. Polygon regions that require a larger quantity of vertices or are concave are defined by multiple polygon geometry using the PhysicsComposer or the PolygonGeometry.CreatePolygons utility. See PhysicsBody.CreateShape.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.U2D.Physics](/engine/6000.5/script-reference/unity/u2d/physics.md)
* **Assembly:** UnityEngine.PhysicsCore2DModule

```csharp
public struct PolygonGeometry
```

## Fields

| Value                                                                                     | Description                                                                                                                                |
| ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| [normals](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/normals.md)   | The geometry normal stored in a [PhysicsShape.ShapeArray](/engine/6000.5/script-reference/unity/u2d/physics/physicsshape/shapearray.md).   |
| [vertices](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/vertices.md) | The geometry vertices stored in a [PhysicsShape.ShapeArray](/engine/6000.5/script-reference/unity/u2d/physics/physicsshape/shapearray.md). |

## Static Fields

| Value                                                                                                   | Description              |
| ------------------------------------------------------------------------------------------------------- | ------------------------ |
| [defaultGeometry](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/defaultgeometry.md) | Get the default Polygon. |

## Constructors

| Constructor                                                                                    | Description                                                                                                                              |
| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| [PolygonGeometry()](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/ctor.md) | Create a default Polygon. See [\_defaultGeometry](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/defaultgeometry.md). |

## Properties

| Property                                                                                  | Description                               |
| ----------------------------------------------------------------------------------------- | ----------------------------------------- |
| [centroid](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/centroid.md) | The centroid of the polygon.              |
| [count](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/count.md)       | The number of polygon vertices.           |
| [isValid](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/isvalid.md)   | Check if the geometry is valid or not.    |
| [radius](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/radius.md)     | The external radius for rounded polygons. |

## Methods

| Method                                                                                                                        | Description                                                                                                                                                                                                                                                                                                                                                                                             |
| ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [AsReadOnlySpan](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/asreadonlyspan.md)                         | Get the polygon vertices as a read-only span.                                                                                                                                                                                                                                                                                                                                                           |
| [AsSpan](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/asspan.md)                                         | Get the polygon vertices as a span.                                                                                                                                                                                                                                                                                                                                                                     |
| [CalculateAABB](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/calculateaabb.md)                           | Calculate the AABB of the geometry.                                                                                                                                                                                                                                                                                                                                                                     |
| [CalculateMassConfiguration](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/calculatemassconfiguration.md) | Calculate the mass configuration of the geometry.                                                                                                                                                                                                                                                                                                                                                       |
| [CastRay](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/castray.md)                                       | Calculate if a world ray intersects the geometry. See [PhysicsQuery.CastResult](/engine/6000.5/script-reference/unity/u2d/physics/physicsquery/castresult.md).                                                                                                                                                                                                                                          |
| [CastShape](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/castshape.md)                                   | Calculate if a cast shape intersects the geometry. Initially touching shapes are treated as a miss. You should check for overlap first if initial overlap is required. See [PhysicsQuery.CastShapeInput](/engine/6000.5/script-reference/unity/u2d/physics/physicsquery/castshapeinput.md) and [PhysicsQuery.CastResult](/engine/6000.5/script-reference/unity/u2d/physics/physicsquery/castresult.md). |
| [ClosestPoint](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/closestpoint.md)                             | Calculate the closest point on this geometry to the specified point.                                                                                                                                                                                                                                                                                                                                    |
| [CreateShapeProxy](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/createshapeproxy.md)                     | Create a shape proxy from the geometry.                                                                                                                                                                                                                                                                                                                                                                 |
| [Intersect](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/intersect.md)                                   | Check the intersection between this geometry and another.                                                                                                                                                                                                                                                                                                                                               |
| [InverseTransform](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/inversetransform.md)                     | Inverse-Transform the geometry.                                                                                                                                                                                                                                                                                                                                                                         |
| [OverlapPoint](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/overlappoint.md)                             | Calculate if a point overlaps the geometry.                                                                                                                                                                                                                                                                                                                                                             |
| [Transform](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/transform.md)                                   | Transform the specified geometry.                                                                                                                                                                                                                                                                                                                                                                       |
| [Validate](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/validate.md)                                     | Get a validated version of the geometry, if possible.                                                                                                                                                                                                                                                                                                                                                   |

## Static Methods

| Method                                                                                                    | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| --------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Create](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/create.md)                     | Create a Polygon from the specified vertices. The number of vertices must be in the range 3 to [PhysicsConstants.MaxPolygonVertices](/engine/6000.5/script-reference/unity/u2d/physics/physicsconstants/maxpolygonvertices.md).                                                                                                                                                                                                                                                                                         |
| [CreateBox](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/createbox.md)               | Create a Polygon as a four-sided box.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| [CreatePolygons](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/createpolygons.md)     | Create multiple [PolygonGeometry](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry.md) from a set of vertices. The vertices are assumed to produce a closed loop but can describe a concave shape if required. There must be at least 3 vertices. A limit is imposed on small vertex distances so be aware that this overload uses a vertex scale of [\_one](/engine/6000.5/script-reference/unityengine/vector2/one.md) so consider using the overload which allows you to increase this if required. |
| [DeleteVertex](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/deletevertex.md)         | Delete a vertex from the geometry returning a new geometry with updated normals and centroid.                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [InsertVertex](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/insertvertex.md)         | Insert a vertex into the geometry returning a new geometry with updated normals and centroid.                                                                                                                                                                                                                                                                                                                                                                                                                           |
| [InverseTransform](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/inversetransform.md) | Inverse-Transform a batch of geometry in place. A transform that degenerates the geometry hull writes an invalid (zero-vertex) polygon in its place.                                                                                                                                                                                                                                                                                                                                                                    |
| [Transform](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/transform.md)               | Transform a batch of geometry in place. A transform that degenerates the geometry hull writes an invalid (zero-vertex) polygon in its place.                                                                                                                                                                                                                                                                                                                                                                            |

## Structs

| Struct                                                                                                        | Description                                                                                       |
| ------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| [PolygonGeometry.ConvexHull](/engine/6000.5/script-reference/unity/u2d/physics/polygongeometry/convexhull.md) | A simple convex hull. The hull is not validated by physics so cannot be used directly for shapes. |
