 # TPolygon2

## [TPolygon2](API\Plugins\GeometricObjects\TPolygon2) is a 2D polygon represented as a list of Vertices.

References

Syntax

template<typename T>
class TPolygon2

Remarks

TPolygon2 is a 2D polygon represented as a list of Vertices.

Variables

Name Description

int

Timestamp

A counter that is incremented every time the polygon vertices are modified

TArray< FVector...

Vertices

The list of vertices/corners of the polygon

Constructors

Name Description

TPolygon2()

TPolygon2

(
const TPolygon2& Copy
)

Construct polygon that is a copy of another polygon

TPolygon2

(
const TArray< FVector2< T >>& Vert...
)

Construct polygon with given list of vertices

Functions

Name Description

void

AppendVertex

(
const FVector2< T >& Position
)

Add a vertex to the Polygon

void

AppendVertices

(
const TArray< FVector2< T >>& NewV...
)

Add a list of Vertices to the Polygon

T

Area()

T

AverageEdgeLength()

TAxisAligned...

Bounds()

void

Chamfer

(
T ChamferDist,
T MinConvexAngleDeg,
T MinConcaveAngleDeg
)

Chamfer each vertex corner of the Polygon

bool

Contains

(
const TSegment2< T >& Segment
)

bool

Contains

(
const TPolygon2< T >& OtherPoly
)

bool

Contains

(
const FVector2< T >& QueryPoint
)

T

DistanceSquared

(
const FVector2< T >& QueryPoint,
int& NearestSegIndexOut,
T& NearestSegParamOut
)

Calculate the squared distance from a point to the polygon

T

DistanceSquared

(
const FVector2< T >& QueryPoint
)

Calculate the squared distance from a point to the polygon

bool

FindIntersections

(
const TPolygon2< T >& OtherPoly,
TArray< FVector2< T >>& OutArray
)

Find all the points where an edge of the Polygon intersects an edge of the OtherPolygon

FVector2< T ...

GetNormal

(
int iSeg,
T SegmentParam
)

FVector2< T ...

GetNormal

(
int VertexIndex
)

Get the normal vector at a vertex of the polygon, which is perpendicular to GetTangent() Points "inward" for a Clockwise Polygon, and outward for CounterClockwise

FVector2< T ...

GetNormal_FaceAvg

(
int VertexIndex
)

Construct a normal at a vertex of the Polygon by averaging the adjacent face normals.

FVector2< T ...

GetSegmentPoint

(
int SegmentIndex,
T SegmentParam
)

FVector2< T ...

GetSegmentPointUnitParam

(
int SegmentIndex,
T SegmentParam
)

FVector2< T ...

GetTangent

(
int VertexIndex
)

Get the tangent vector at a vertex of the polygon, which is the normalized vector from the previous vertex to the next vertex

int

GetTimestamp()

const TArray...

GetVertices()

bool

Intersects

(
const TSegment2< T >& Segment
)

bool

Intersects

(
const TPolygon2< T >& OtherPoly
)

bool

IsClockwise()

TPolygon2< T...

MakeCircle

(
int Steps,
)

Construct a circular polygon

TPolygon2< T...

MakeRectangle

(
const FVector2< T >& Center,
T Width,
T Height
)

Construct a four-vertex rectangle polygon

TPolygon2< T...

MakeRoundedRectangle

(
const FVector2< T >& Center,
T Width,
T Height,
T Corner,
int CornerSteps
)

Construct a rounded rectangle polygon

void

NeighbourPoints

(
int iVertex,
FVector2< T >& PrevNbrOut,
FVector2< T >& NextNbrOut
)

Get the previous and next vertex positions for a given vertex of the Polygon

void

NeighbourVectors

(
int iVertex,
FVector2< T >& ToPrevOut,
FVector2< T >& ToNextOut,
bool bNormalize
)

Get the vectors from a given vertex to the previous and next Vertices, optionally normalized

T

OpeningAngleDeg

(
int iVertex
)

bool

Overlaps

(
const TPolygon2< T >& OtherPoly
)

Check for polygon overlap, aka solid intersection.

T

Perimeter()

void

PolyOffset

(
T OffsetDistance
)

Offset polygon by fixed distance, by offsetting and intersecting edges.

void

RemoveVertex

(
int VertexIndex
)

Remove a vertex of the Polygon (existing Vertices are shifted)

void

Reverse()

Reverse the order of the Vertices in the Polygon (ie switch between Clockwise and CounterClockwise)

TPolygon2< T...

Scale

(
const FVector2< T >& Scale,
const FVector2< T >& Origin
)

Scale the Polygon relative to a given point

TSegment2< T...

Segment

(
int SegmentIndex
)

SegmentItera...

SegmentItr()

SegmentEnume...

Segments()

void

Set

(
int VertexIndex,
const FVector2< T >& Position
)

Set vertex at given index to a new Position

void

SetVertices

(
const TArray< FVector2< T >>& NewV...
)

Replace the list of Vertices with a new list

T

SignedArea()

void

Simplify

(
T ClusterTolerance,
T LineDeviationTolerance
)

Simplify the Polygon to reduce the vertex count

const FVecto...

Start()

TPolygon2< T...

Transform

(
const TFunction< FVector2< T >(cons...
)

Apply an arbitrary transformation to the Polygon

TPolygon2< T...

Translate

(
const FVector2< T >& Translate
)

Translate the polygon

int

VertexCount()

void

VtxNormalOffset

(
T OffsetDistance,
bool bUseFaceAvg
)

Offset each point by the given Distance along vertex "normal" direction

T

WindingIntegral

(
const FVector2< T >& QueryPoint
)

Operators

Name Description

FVector2< T ...

operator[]

(
int Index
)

Get the vertex at a given index

const FVecto...

operator[]

(
int Index
)

Get the vertex at a given index

Classes

Name

Description

SegmentEnumerable

Wrapper around SegmentIterator that has begin() and end() suitable for range-based for loop

SegmentIterator

SegmentIterator is used to iterate over the TSegment2 segments of the polygon

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.