TPolygon2

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

Windows
MacOS
Linux

References

Module

GeometricObjects

Header

/Engine/Plugins/Experimental/GeometryProcessing/Source/GeometricObjects/Public/Polygon2.h

Include

#include "Polygon2.h"

Syntax

template<typename T>
class TPolygon2

Remarks

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

Variables

Name Description

Protected variable

int

 

Timestamp

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

Protected variable

TArray< FVector...

 

Vertices

The list of vertices/corners of the polygon

Constructors

Name Description

Public function

TPolygon2()

Public function

TPolygon2

(
    const TPolygon2& Copy
)

Construct polygon that is a copy of another polygon

Public function

TPolygon2

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

Construct polygon with given list of vertices

Functions

Name Description

Public function

void

 

AppendVertex

(
    const FVector2< T >& Position
)

Add a vertex to the Polygon

Public function

void

 

AppendVertices

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

Add a list of Vertices to the Polygon

Public function Const

T

 

Area()

Public function Const

T

 

AverageEdgeLength()

Public function Const

TAxisAligned...

 

Bounds()

Public function

void

 

Chamfer

(
    T ChamferDist,
    T MinConvexAngleDeg,
    T MinConcaveAngleDeg
)

Chamfer each vertex corner of the Polygon

Public function Const

bool

 

Contains

(
    const TSegment2< T >& Segment
)

Public function Const

bool

 

Contains

(
    const TPolygon2< T >& OtherPoly
)

Public function Const

bool

 

Contains

(
    const FVector2< T >& QueryPoint
)

Public function Const

T

 

DistanceSquared

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

Calculate the squared distance from a point to the polygon

Public function Const

T

 

DistanceSquared

(
    const FVector2< T >& QueryPoint
)

Calculate the squared distance from a point to the polygon

Public function Const

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

Public function Const

FVector2< T ...

 

GetNormal

(
    int iSeg,
    T SegmentParam
)

Public function Const

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

Public function Const

FVector2< T ...

 

GetNormal_FaceAvg

(
    int VertexIndex
)

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

Public function Const

FVector2< T ...

 

GetSegmentPoint

(
    int SegmentIndex,
    T SegmentParam
)

Public function Const

FVector2< T ...

 

GetSegmentPointUnitParam

(
    int SegmentIndex,
    T SegmentParam
)

Public function Const

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

Public function Const

int

 

GetTimestamp()

Public function Const

const TArray...

 

GetVertices()

Public function Const

bool

 

Intersects

(
    const TSegment2< T >& Segment
)

Public function Const

bool

 

Intersects

(
    const TPolygon2< T >& OtherPoly
)

Public function Const

bool

 

IsClockwise()

Public function Static

TPolygon2< T...

 

MakeCircle

(
    T Radius,
    int Steps,
    T AngleShiftRadians
)

Construct a circular polygon

Public function Static

TPolygon2< T...

 

MakeRectangle

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

Construct a four-vertex rectangle polygon

Public function Static

TPolygon2< T...

 

MakeRoundedRectangle

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

Construct a rounded rectangle polygon

Public function Const

void

 

NeighbourPoints

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

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

Public function Const

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

Public function Const

T

 

OpeningAngleDeg

(
    int iVertex
)

Public function Const

bool

 

Overlaps

(
    const TPolygon2< T >& OtherPoly
)

Check for polygon overlap, aka solid intersection.

Public function Const

T

 

Perimeter()

Public function

void

 

PolyOffset

(
    T OffsetDistance
)

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

Public function

void

 

RemoveVertex

(
    int VertexIndex
)

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

Public function

void

 

Reverse()

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

Public function

TPolygon2< T...

 

Scale

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

Scale the Polygon relative to a given point

Public function Const

TSegment2< T...

 

Segment

(
    int SegmentIndex
)

Public function Const

SegmentItera...

 

SegmentItr()

Public function Const

SegmentEnume...

 

Segments()

Public function

void

 

Set

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

Set vertex at given index to a new Position

Public function

void

 

SetVertices

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

Replace the list of Vertices with a new list

Public function Const

T

 

SignedArea()

Public function

void

 

Simplify

(
    T ClusterTolerance,
    T LineDeviationTolerance
)

Simplify the Polygon to reduce the vertex count

Public function Const

const FVecto...

 

Start()

Public function

TPolygon2< T...

 

Transform

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

Apply an arbitrary transformation to the Polygon

Public function

TPolygon2< T...

 

Translate

(
    const FVector2< T >& Translate
)

Translate the polygon

Public function Const

int

 

VertexCount()

Public function

void

 

VtxNormalOffset

(
    T OffsetDistance,
    bool bUseFaceAvg
)

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

Public function Const

T

 

WindingIntegral

(
    const FVector2< T >& QueryPoint
)

Operators

Name Description

Public function

FVector2< T ...

 

operator[]

(
    int Index
)

Get the vertex at a given index

Public function Const

const FVecto...

 

operator[]

(
    int Index
)

Get the vertex at a given index

Classes

Name

Description

Public class

SegmentEnumerable

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

Public class

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.
Take our survey
Dismiss