Language:
Discover
By Skill Level
By Category

FVector2D

Choose your OS:

Syntax

struct FVector2D

Remarks

A vector in 2-D space composed of components (X, Y) with floating point precision.

A point or direction FVector in 2d space. The full C++ class is located here: Engine\Source\Runtime\Core\Public\Math\Vector2D.h

Variables

Name Description

Public variable

float

 

X

Vector's X component.

Public variable

float

 

Y

Vector's Y component.

Constructors

Name Description

Public function

FVector2D()

Default constructor (no initialization).

Public function

FVector2D

(
    FIntPoint InPos
)

Constructs a vector from an FIntPoint .

Public function

FVector2D

(
    EForceInit
)

Constructor which initializes all components to zero.

Public function

FVector2D

(
    ENoInit
)

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

Public function

FVector2D

(
    const FVector & V
)

Constructs a vector from an FVector .

Public function

FVector2D

(
    float InX,
    float InY
)

Constructor using initial values for each component.

Functions

Name Description

Public function

FVector2D

 

ClampAxes

(
    float MinAxisVal,
    float MaxAxisVal
)

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

Public function

float

 

Component

(
    int32 Index
)

Gets a specific component of the vector.

Copy of the specified component.

Public function

float &

 

Component

(
    int32 Index
)

Gets a specific component of the vector.

Reference to the specified component.

Public function

bool

 

ContainsNaN()

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

Public function Static

float

 

CrossProduct

(
    const FVector2D & A,
    const FVector2D & B
)

Calculate the cross product of two vectors.

The cross product.

Public function

void

 

DiagnosticCheckNaN()

Public function Static

float

 

Distance

(
    const FVector2D & V1,
    const FVector2D & V2
)

Distance between two 2D points.

The distance between two 2D points.

Public function Static

float

 

DistSquared

(
    const FVector2D & V1,
    const FVector2D & V2
)

Squared distance between two 2D points.

The squared distance between two 2D points.

Public function Static

float

 

DotProduct

(
    const FVector2D & A,
    const FVector2D & B
)

Calculates the dot product of two vectors.

The dot product.

Public function

bool

 

Equals

(
    const FVector2D & V,
    float Tolerance
)

Checks for equality with error-tolerant comparison.

Public function

FVector2D

 

GetAbs()

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

Public function

float

 

GetAbsMax()

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

Public function

float

 

GetMax()

Get the maximum value of the vector's components.

The maximum value of the vector's components.

Public function

float

 

GetMin()

Get the minimum value of the vector's components.

The minimum value of the vector's components.

Public function

FVector2D

 

GetRotated

(
    float AngleDeg
)

Rotates around axis (0,0,1)

Rotated Vector

Public function

FVector2D

 

GetSafeNormal

(
    float Tolerance
)

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

Public function

FVector2D

 

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

FIntPoint

 

IntPoint()

Get this vector as an Int Point.

New Int Point from this vector.

Public function

bool

 

IsNearlyZero

(
    float Tolerance
)

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

Public function

bool

 

IsZero()

Checks whether all components of the vector are exactly zero.

Public function

[CORE_API](API\Runtime\Core\Misc\CORE_API_1) boo...

 

NetSerialize

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

Network serialization function.

Public function

void

 

Normalize

(
    float Tolerance
)

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

Public function

FVector2D

 

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

void

 

Set

(
    float InX,
    float InY
)

Set the values of the vector directly.

Public function

float

 

Size()

Get the length (magnitude) of this vector.

The length of this vector.

Public function

float

 

SizeSquared()

Get the squared length of this vector.

The squared length of this vector.

Public function

FVector

 

SphericalToUnitCartesian()

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

Public function

void

 

ToDirectionAndLength

(
    FVector2D & OutDir,
    float& OutLength
)

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

Public function

FString

 

ToString()

Get a textual representation of the vector.

Text describing the vector.

Operators

Name Description

Public function

FVector2D

 

operator-

(
    const FVector2D & V
)

Gets the result of subtracting a vector from this one.

The result of the subtraction.

Public function

FVector2D

 

operator-()

Gets a negated copy of the vector.

A negated copy of the vector.

Public function

FVector2D

 

operator-

(
    float A
)

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

Public function

bool

 

operator!=

(
    const FVector2D & V
)

Compares this vector against another for inequality.

Public function

FVector2D

 

operator*

(
    float Scale
)

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

Public function

FVector2D

 

operator*

(
    const FVector2D & V
)

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

Public function

FVector2D

 

operator*=

(
    const FVector2D & V
)

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

Public function

FVector2D

 

operator*=

(
    float Scale
)

Scales this vector.

Copy of the vector after scaling.

Public function

FVector2D

 

operator/

(
    const FVector2D & V
)

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

Public function

FVector2D

 

operator/

(
    float Scale
)

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

Public function

FVector2D

 

operator/=

(
    float V
)

Divides this vector.

Copy of the vector after division.

Public function

FVector2D

 

operator/=

(
    const FVector2D & V
)

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

Public function

float &

 

operator[]

(
    int32 Index
)

Gets specific component of the vector.

reference to component.

Public function

float

 

operator[]

(
    int32 Index
)

Gets specific component of the vector.

copy of component value.

Public function

float

 

operator^

(
    const FVector2D & V
)

Calculates cross product of this vector and another.

The cross product.

Public function

float

 

operator|

(
    const FVector2D & V
)

Calculates dot product of this vector and another.

The dot product.

Public function

FVector2D

 

operator+

(
    const FVector2D & V
)

Gets the result of adding two vectors together.

The result of adding the vectors together.

Public function

FVector2D

 

operator+

(
    float A
)

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

Public function

FVector2D

 

operator+=

(
    const FVector2D & V
)

Adds another vector to this.

Copy of the vector after addition.

Public function

bool

 

operator<

(
    const FVector2D & Other
)

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

Public function

bool

 

operator<=

(
    const FVector2D & Other
)

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

Public function

FVector2D

 

operator-=

(
    const FVector2D & V
)

Subtracts another vector from this.

Copy of the vector after subtraction.

Public function

bool

 

operator==

(
    const FVector2D & V
)

Compares this vector against another for equality.

Public function

bool

 

operator>

(
    const FVector2D & Other
)

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

Public function

bool

 

operator>=

(
    const FVector2D & Other
)

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

Constants

Name

Description

UnitVector

Global 2D unit vector constant (1,1)

ZeroVector

Global 2D zero vector constant (0,0)

References

Module

Core

Header

Runtime/Core/Public/Math/Vector2D.h