TVector2

Choose your operating system:

Windows

macOS

Linux

Inheritance Hierarchy

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/CoreFwd.h

Include

#include "CoreFwd.h"

Syntax

template<typename T>
struct TVector2

Variables

Name Description

Public variable

T

 

X

Vector's X component.

Public variable

T

 

Y

Vector's Y component.

Constructors

Name Description

Public function

TVector2()

Default constructor (no initialization).

Public function

TVector2

(
    T InF
)

Constructor initializing both components to a single T value.

Public function

TVector2

(
    FIntPoint InPos
)

Constructs a vector from an FIntPoint.

Public function

TVector2

(
    EForceInit
)

Constructor which initializes all components to zero.

Public function

TVector2

(
    ENoInit
)

Constructor that does not initialize. More explicit than the default constructor.

Public function

TVector2

(
    const TVector< T >& V
)

Constructs a vector from an FVector. Copies the X and Y components from the FVector.

Public function

TVector2

(
    const TVector4< T >& V
)

Constructs a vector from an FVector4.

Public function

TVector2

(
    const TVector2< FArg >& From
)

Conversion from other type. TODO: explicit!

Public function

TVector2

(
    T InX,
    T InY
)

Constructor using initial values for each component.

Functions

Name Description

Public function Const

TVector2< T ...

 

ClampAxes

(
    T MinAxisVal,
    T MaxAxisVal
)

Creates a copy of this vector with both axes clamped to the given range.

Public function Const

T

 

Component

(
    int32 Index
)

Gets a specific component of the vector.

Public function

T &

 

Component

(
    int32 Index
)

Gets a specific component of the vector.

Public function Const

bool

 

ContainsNaN()

Utility to check if there are any non-finite values (NaN or Inf) in this vector.

Public function Static

T

 

CrossProduct

(
    const TVector2< T >& A,
    const TVector2< T >& B
)

Calculate the cross product of two vectors.

Public function

void

 

DiagnosticCheckNaN()

Public function Static

T

 

Distance

(
    const TVector2< T >& V1,
    const TVector2< T >& V2
)

Distance between two 2D points.

Public function Static

T

 

DistSquared

(
    const TVector2< T >& V1,
    const TVector2< T >& V2
)

Squared distance between two 2D points.

Public function Const

T

 

Dot

(
    const TVector2< T >& V2
)

Get the dot product of this vector against another.

Public function Static

T

 

DotProduct

(
    const TVector2< T >& A,
    const TVector2< T >& B
)

Calculates the dot product of two vectors.

Public function Const

bool

 

Equals

(
    const TVector2< T >& V,
    T Tolerance
)

Checks for equality with error-tolerant comparison.

Public function Const

TVector2< T ...

 

GetAbs()

Get a copy of this vector with absolute value of each component.

Public function Const

T

 

GetAbsMax()

Get the maximum absolute value of the vector's components.

Public function Const

T

 

GetMax()

Get the maximum value of the vector's components.

Public function Const

T

 

GetMin()

Get the minimum value of the vector's components.

Public function Const

TVector2< T ...

 

GetRotated

(
    T AngleDeg
)

Rotates around axis (0,0,1)

Public function Const

TVector2< T ...

 

GetSafeNormal

(
    T Tolerance
)

Gets a normalized copy of the vector, checking it is safe to do so based on the length.

Public function Const

TVector2< T ...

 

GetSignVector()

Get a copy of the vector as sign only.

Public function

bool

 

InitFromString

(
    const FString& InSourceString
)

Initialize this Vector based on an FString.

Public function Const

FIntPoint

 

IntPoint()

Get this vector as an Int Point.

Public function Const

bool

 

IsNearlyZero

(
    T Tolerance
)

Checks whether vector is near to zero within a specified tolerance.

Public function Const

bool

 

IsZero()

Checks whether all components of the vector are exactly zero.

Public function Const

T

 

Length()

Get the length (magnitude) of this vector.

Public function Static

TVector2< T ...

 

Max

(
    const TVector2< T >& A,
    const TVector2< T >& B
)

Returns a vector with the maximum component for each dimension from the pair of vectors.

Public function Static

TVector2< T ...

 

Min

(
    const TVector2< T >& A,
    const TVector2< T >& B
)

Returns a vector with the minimum component for each dimension from the pair of vectors.

Public function

bool

 

NetSerialize

(
    FArchive& Ar,
    UPackageMap* Map,
    bool& bOutSuccess
)

Network serialization function.

Public function

void

 

Normalize

(
    T Tolerance
)

Normalize this vector in-place if it is large enough, set it to (0,0) otherwise.

Public function Static

TVector2< T ...

 

One()

Public function Const

TVector2< T ...

 

RoundToVector()

Get this vector as a vector where each component has been rounded to the nearest int.

Public function

bool

 

Serialize

(
    FArchive& Ar
)

Public function

bool

 

Serialize

(
    FStructuredArchive::FSlot Slot
)

Public function

bool

 

SerializeFromMismatchedTag

(
    FName StructTag,
    FArchive& Ar
)

Public function

void

 

Set

(
    T InX,
    T InY
)

Set the values of the vector directly.

Public function Const

T

 

Size()

Get the length (magnitude) of this vector.

Public function Const

T

 

SizeSquared()

Get the squared length of this vector.

Public function Const

TVector< T >

 

SphericalToUnitCartesian()

Converts spherical coordinates on the unit sphere into a Cartesian unit length vector.

Public function Const

T

 

SquaredLength()

Get the squared length of this vector.

Public function Const

void

 

ToDirectionAndLength

(
    TVector2< T >& OutDir,
    double& OutLength
)

Util to convert this vector into a unit direction vector and its original length.

Public function Const

void

 

ToDirectionAndLength

(
    TVector2< T >& OutDir,
    float& OutLength
)

Util to convert this vector into a unit direction vector and its original length.

Public function Const

FString

 

ToString()

Get a textual representation of the vector.

Public function Static

TVector2< T ...

 

UnitX()

Public function Static

TVector2< T ...

 

UnitY()

Public function Static

TVector2< T ...

 

Zero()

Operators

Name Description

Public function Const

TVector2< T ...

 

operator-()

Gets a negated copy of the vector.

Public function Const

TVector2< T ...

 

operator-

(
    T A
)

Gets the result of subtracting A from each component of the vector.

Public function Const

TVector2< T ...

 

operator-

(
    const TVector2< T >& V
)

Gets the result of subtracting a vector from this one.

Public function Const

bool

 

operator!=

(
    const TVector2< T >& V
)

Compares this vector against another for inequality.

Public function Const

TVector2< T ...

 

operator*

(
    const TVector2< T >& V
)

Gets the result of component-wise multiplication of this vector by another.

Public function Const

TVector2< T ...

 

operator*

(
    T Scale
)

Gets the result of scaling the vector (multiplying each component by a value).

Public function

TVector2< T ...

 

operator*=

(
    const TVector2< T >& V
)

Multiplies this vector with another vector, using component-wise multiplication.

Public function

TVector2< T ...

 

operator*=

(
    T Scale
)

Scales this vector.

Public function Const

TVector2< T ...

 

operator/

(
    T Scale
)

Gets the result of dividing each component of the vector by a value.

Public function Const

TVector2< T ...

 

operator/

(
    const TVector2< T >& V
)

Gets the result of component-wise division of this vector by another.

Public function

TVector2< T ...

 

operator/=

(
    T V
)

Divides this vector.

Public function

TVector2< T ...

 

operator/=

(
    const TVector2< T >& V
)

Divides this vector by another vector, using component-wise division.

Public function Const

T

 

operator[]

(
    int32 Index
)

Gets specific component of the vector.

Public function

T &

 

operator[]

(
    int32 Index
)

Gets specific component of the vector.

Public function Const

T

 

operator^

(
    const TVector2< T >& V
)

Calculates cross product of this vector and another.

Public function Const

T

 

operator|

(
    const TVector2< T >& V
)

Calculates dot product of this vector and another.

Public function Const

TVector2< T ...

 

operator+

(
    T A
)

Gets the result of adding A to each component of the vector.

Public function Const

TVector2< T ...

 

operator+

(
    const TVector2< T >& V
)

Gets the result of adding two vectors together.

Public function

TVector2< T ...

 

operator+=

(
    const TVector2< T >& V
)

Adds another vector to this.

Public function Const

bool

 

operator<

(
    const TVector2< T >& Other
)

Checks whether both components of this vector are less than another.

Public function Const

bool

 

operator<=

(
    const TVector2< T >& Other
)

Checks whether both components of this vector are less than or equal to another.

Public function

TVector2< T ...

 

operator-=

(
    const TVector2< T >& V
)

Subtracts another vector from this.

Public function Const

bool

 

operator==

(
    const TVector2< T >& V
)

Compares this vector against another for equality.

Public function Const

bool

 

operator>

(
    const TVector2< T >& Other
)

Checks whether both components of this vector are greater than another.

Public function Const

bool

 

operator>=

(
    const TVector2< T >& Other
)

Checks whether both components of this vector are greater than or equal to another.

Typedefs

Name

Description

FReal

Constants

Name

Description

Unit45Deg

Global 2D unit vector constant along the 45 degree angle or symmetrical positive axes (sqrt(.5),sqrt(.5)) or (.707,.707).

UnitVector

Global 2D one vector (poorly named) constant (1,1).

ZeroVector

Global 2D zero vector constant (0,0)