UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::Geometry::TSegment2< T > Struct Template Reference

#include <SegmentTypes.h>

Public Member Functions

 TSegment2 ()=default
 
 TSegment2 (const TVector2< T > &Point0, const TVector2< T > &Point1)
 
 TSegment2 (const TVector2< T > &CenterIn, const TVector2< T > &DirectionIn, T ExtentIn)
 
void SetStartPoint (const TVector2< T > &Point)
 
void SetEndPoint (const TVector2< T > &Point)
 
void Reverse ()
 
TVector2< T > StartPoint () const
 
TVector2< T > EndPoint () const
 
Length () const
 
TVector2< T > GetPointFromIndex (int i) const
 
TVector2< T > PointAt (T DistanceParameter) const
 
TVector2< T > PointBetween (T UnitParameter) const
 
ConvertToUnitRange (T DistanceParameter) const
 
DistanceSquared (const TVector2< T > &Point) const
 
DistanceSquared (const TVector2< T > &Point, T &DistParameterOut) const
 
TVector2< T > NearestPoint (const TVector2< T > &QueryPoint) const
 
Project (const TVector2< T > &QueryPoint) const
 
ProjectUnitRange (const TVector2< T > &QueryPoint) const
 
int GetSide (const TVector2< T > &QueryPoint, T Tolerance=0)
 
int WhichSide (const TVector2< T > &QueryPoint, T Tolerance=0)
 
bool Intersects (const TSegment2< T > &OtherSegment, T DotThresh=TMathUtil< T >::Epsilon, T IntervalThresh=0) const
 

Static Public Member Functions

staticFastDistanceSquared (const TVector2< T > &StartPt, const TVector2< T > &EndPt, const TVector2< T > &QueryPt, T Tolerance=TMathUtil< T >::Epsilon)
 
static int GetSide (const TVector2< T > &StartPt, const TVector2< T > &EndPt, const TVector2< T > &QueryPt, T Tolerance=(T) 0)
 
static int WhichSide (const TVector2< T > &StartPt, const TVector2< T > &EndPt, const TVector2< T > &QueryPt, T Tolerance=(T) 0)
 
static bool IsOnSegment (const TVector2< T > &A, const TVector2< T > &B, const TVector2< T > &QueryPt, T Tolerance=(T) 0)
 

Public Attributes

TVector2< T > Center = TVector2<T>::Zero()
 
TVector2< T > Direction = TVector2<T>::UnitX()
 
Extent = (T)0
 

Protected Member Functions

void update_from_endpoints (const TVector2< T > &p0, const TVector2< T > &p1)
 

Constructor & Destructor Documentation

◆ TSegment2() [1/3]

template<typename T >
UE::Geometry::TSegment2< T >::TSegment2 ( )
default

◆ TSegment2() [2/3]

template<typename T >
UE::Geometry::TSegment2< T >::TSegment2 ( const TVector2< T > &  Point0,
const TVector2< T > &  Point1 
)
inline

Construct a Segment from two Points

◆ TSegment2() [3/3]

template<typename T >
UE::Geometry::TSegment2< T >::TSegment2 ( const TVector2< T > &  CenterIn,
const TVector2< T > &  DirectionIn,
ExtentIn 
)
inline

Construct a segment from a Center Point, normalized Direction, and scalar Extent

Member Function Documentation

◆ ConvertToUnitRange()

template<typename T >
T UE::Geometry::TSegment2< T >::ConvertToUnitRange ( DistanceParameter) const
inline
Parameters
DistanceParameterdistance on the segment from the segment Origin in range [-Extent, Extent]
Returns
unit value in range [0,1]

◆ DistanceSquared() [1/2]

template<typename T >
T UE::Geometry::TSegment2< T >::DistanceSquared ( const TVector2< T > &  Point) const
inline
Returns
minimum squared distance from Point to segment

◆ DistanceSquared() [2/2]

template<typename T >
T UE::Geometry::TSegment2< T >::DistanceSquared ( const TVector2< T > &  Point,
T &  DistParameterOut 
) const
inline
Parameters
Pointquery point
DistParameterOutcalculated distance parameter in range [-Extent,Extent]
Returns
minimum squared distance from Point to Segment

◆ EndPoint()

template<typename T >
TVector2< T > UE::Geometry::TSegment2< T >::EndPoint ( ) const
inline
Returns
end point of segment

◆ FastDistanceSquared()

template<typename T >
static T UE::Geometry::TSegment2< T >::FastDistanceSquared ( const TVector2< T > &  StartPt,
const TVector2< T > &  EndPt,
const TVector2< T > &  QueryPt,
Tolerance = TMathUtil<T>::Epsilon 
)
inlinestatic

Calculate distance from QueryPoint to segment (StartPt,EndPt)

◆ GetPointFromIndex()

template<typename T >
TVector2< T > UE::Geometry::TSegment2< T >::GetPointFromIndex ( int  i) const
inline
Returns
first (i == 0) or second (i == 1) endpoint of the Segment

◆ GetSide() [1/2]

template<typename T >
int UE::Geometry::TSegment2< T >::GetSide ( const TVector2< T > &  QueryPoint,
Tolerance = 0 
)
inline

Determine which side of the segment the query point lies on.

Parameters
QueryPointtest point
Tolerancetolerance band in which we return 0
Returns
-1 if point is to right of line, +1 if left, and 0 if on line or within tolerance band

◆ GetSide() [2/2]

template<typename T >
static int UE::Geometry::TSegment2< T >::GetSide ( const TVector2< T > &  StartPt,
const TVector2< T > &  EndPt,
const TVector2< T > &  QueryPt,
Tolerance = (T)0 
)
inlinestatic

Determine which side of the segment the query point lies on.

Parameters
StartPtfirst point of Segment
EndPtsecond point of Segment
QueryPointtest point
Tolerancetolerance band in which we return 0. Note that using tolerance == 0 is faster because we do not need to get distance of point from segment line.
Returns
-1 if point is to right of line, +1 if left, and 0 if on line or within tolerance band, or segment was degenerate

◆ Intersects()

template<typename T >
bool UE::Geometry::TSegment2< T >::Intersects ( const TSegment2< T > &  OtherSegment,
DotThresh = TMathUtil<T>::Epsilon,
IntervalThresh = 0 
) const
inline

Test if this segment intersects with OtherSegment. Returns true for parallel-line overlaps. Returns same result as IntrSegment2Segment2

Parameters
OtherSegmentsegment to test against
DotThreshdot-product tolerance used to determine if segments are parallel
IntervalThreshdistance tolerance used to allow slighly-not-touching segments to be considered overlapping
Returns
true if segments intersect

◆ IsOnSegment()

template<typename T >
static bool UE::Geometry::TSegment2< T >::IsOnSegment ( const TVector2< T > &  A,
const TVector2< T > &  B,
const TVector2< T > &  QueryPt,
Tolerance = (T)0 
)
inlinestatic

Return true if QueryPt is on the segment between A and B.

◆ Length()

template<typename T >
T UE::Geometry::TSegment2< T >::Length ( ) const
inline
Returns
the Length of the segment

◆ NearestPoint()

template<typename T >
TVector2< T > UE::Geometry::TSegment2< T >::NearestPoint ( const TVector2< T > &  QueryPoint) const
inline
Returns
nearest point on segment to QueryPoint

◆ PointAt()

template<typename T >
TVector2< T > UE::Geometry::TSegment2< T >::PointAt ( DistanceParameter) const
inline
Returns
point on segment at given (signed) Distance from the segment Origin

◆ PointBetween()

template<typename T >
TVector2< T > UE::Geometry::TSegment2< T >::PointBetween ( UnitParameter) const
inline
Parameters
UnitParametervalue in range [0,1]
Returns
point on segment at that linearly interpolates between start and end based on Unit Parameter

◆ Project()

template<typename T >
T UE::Geometry::TSegment2< T >::Project ( const TVector2< T > &  QueryPoint) const
inline
Returns
scalar projection of QueryPoint onto line of Segment (not clamped to Extents)

◆ ProjectUnitRange()

template<typename T >
T UE::Geometry::TSegment2< T >::ProjectUnitRange ( const TVector2< T > &  QueryPoint) const
inline
Returns
scalar projection of QueryPoint onto line of Segment, mapped to [0,1] range along segment

◆ Reverse()

template<typename T >
void UE::Geometry::TSegment2< T >::Reverse ( )
inline

Reverse the segment

◆ SetEndPoint()

template<typename T >
void UE::Geometry::TSegment2< T >::SetEndPoint ( const TVector2< T > &  Point)
inline

Update the Segment with a new end point

◆ SetStartPoint()

template<typename T >
void UE::Geometry::TSegment2< T >::SetStartPoint ( const TVector2< T > &  Point)
inline

Update the Segment with a new start point

◆ StartPoint()

template<typename T >
TVector2< T > UE::Geometry::TSegment2< T >::StartPoint ( ) const
inline
Returns
start point of segment

◆ update_from_endpoints()

template<typename T >
void UE::Geometry::TSegment2< T >::update_from_endpoints ( const TVector2< T > &  p0,
const TVector2< T > &  p1 
)
inlineprotected

◆ WhichSide() [1/2]

template<typename T >
int UE::Geometry::TSegment2< T >::WhichSide ( const TVector2< T > &  QueryPoint,
Tolerance = 0 
)
inline

Determine which side of the segment the query point lies on. This version is deprecated because it and the static function give opposite results. It also does not correctly handle tolerance.

Parameters
QueryPointtest point
Tolerancetolerance band in which we return 0
Returns
-1 if point is to right of line, +1 if left, and 0 if on line or within tolerance band

◆ WhichSide() [2/2]

template<typename T >
static int UE::Geometry::TSegment2< T >::WhichSide ( const TVector2< T > &  StartPt,
const TVector2< T > &  EndPt,
const TVector2< T > &  QueryPt,
Tolerance = (T)0 
)
inlinestatic

Determine which side of the segment the query point lies on. This version is deprecated because it and the member function give opposite results. It also does not correctly handle tolerance.

Parameters
StartPtfirst point of Segment
EndPtsecond point of Segment
QueryPointtest point
Tolerancetolerance band in which we return 0
Returns
+1 if point is to right of line, -1 if left, and 0 if on line or within tolerance band

Member Data Documentation

◆ Center

template<typename T >
TVector2<T> UE::Geometry::TSegment2< T >::Center = TVector2<T>::Zero()

Center point of segment

◆ Direction

template<typename T >
TVector2<T> UE::Geometry::TSegment2< T >::Direction = TVector2<T>::UnitX()

normalized Direction vector of segment

◆ Extent

template<typename T >
T UE::Geometry::TSegment2< T >::Extent = (T)0

Extent of segment, which is half the total length


The documentation for this struct was generated from the following files: