FVector

Inheritance Hierarchy

Syntax

struct FVector

Remarks

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

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

Variables

Name Description

Public variable

float

 

X

Vector's X component.

Public variable

float

 

Y

Vector's Y component.

Public variable

float

 

Z

Vector's Z component.

Constructors

Name Description

Public function

FVector()

Default constructor (no initialization).

Public function

FVector

(
    float InF
)

Constructor initializing all components to a single float value.

Public function

FVector

(
    const FVector4 & V
)

Constructor using the XYZ components from a 4D vector.

Public function

FVector

(
    const FLinearColor & InColor
)

Constructs a vector from an FLinearColor .

Public function

FVector

(
    FIntVector InVector
)

Constructs a vector from an FIntVector .

Public function

FVector

(
    FIntPoint A
)

Constructs a vector from an FIntPoint .

Public function

FVector

(
    EForceInit
)

Constructor which initializes all components to zero.

Public function

FVector

(
    const FVector2D V,
    float InZ
)

Constructs a vector from an FVector2D and Z value.

Public function

FVector

(
    float InX,
    float InY,
    float InZ
)

Constructor using initial values for each component.

Functions

Name Description

Public function

void

 

AddBounded

(
    const FVector & V,
    float Radius
)

Add a vector to this and clamp the result in a cube.

Public function

bool

 

AllComponentsEqual

(
    float Tolerance
)

Checks whether all components of this vector are the same, within a tolerance.

Public function

FVector

 

BoundToCube

(
    float Radius
)

Get a copy of this vector, clamped inside of a cube.

A copy of this vector, bound by cube.

Public function Static

float

 

BoxPushOut

(
    const FVector & Normal,
    const FVector & Size
)

Compute pushout of a box from a plane.

Pushout required.

Public function

FVector

 

ClampMaxSize

(
    float MaxSize
)

Public function

FVector

 

ClampMaxSize2D

(
    float MaxSize
)

Public function

FVector

 

ClampSize

(
    float Min,
    float Max
)

Public function

FVector

 

ClampSize2D

(
    float Min,
    float Max
)

Public function Static

bool

 

Coincident

(
    const FVector & Normal1,
    const FVector & Normal2,
    float ParallelCosineThreshold
)

See if two normal vectors are coincident (nearly parallel and point in the same direction).

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

FVector

 

ComponentMax

(
    const FVector & Other
)

Gets the component-wise max of two vectors.

Public function

FVector

 

ComponentMin

(
    const FVector & Other
)

Gets the component-wise min of two vectors.

Public function

bool

 

ContainsNaN()

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

Public function Static

bool

 

Coplanar

(
    const FVector & Base1,
    const FVector & Normal1,
    const FVector & Base2,
    const FVector & Normal2,
    float ParallelCosineThreshold
)

See if two planes are coplanar.

Public function

float

 

CosineAngle2D

(
    FVector B
)

Returns the cosine of the angle between this vector and another projected onto the XY plane (no Z).

Public function Static

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

 

CreateOrthonormalBasis

(
    FVector & XAxis,
    FVector & YAxis,
    FVector & ZAxis
)

Create an orthonormal basis from a basis with at least two orthogonal vectors.

Public function Static

FVector

 

CrossProduct

(
    const FVector & A,
    const FVector & B
)

Calculate the cross product of two vectors.

The cross product.

Public function Static

FVector

 

DegreesToRadians

(
    const FVector & DegVector
)

Converts a vector containing degree values to a vector containing radian values.

Public function

void

 

DiagnosticCheckNaN()

Public function

void

 

DiagnosticCheckNaN

(
    const TCHAR * Message
)

Public function Static

float

 

Dist

(
    const FVector & V1,
    const FVector & V2
)

Euclidean distance between two points.

The distance between two points.

Public function Static

float

 

Dist2D

(
    const FVector & V1,
    const FVector & V2
)

Public function Static

float

 

Distance

(
    const FVector & V1,
    const FVector & V2
)

Public function Static

float

 

DistSquared

(
    const FVector & V1,
    const FVector & V2
)

Squared distance between two points.

The squared distance between two points.

Public function Static

float

 

DistSquared2D

(
    const FVector & V1,
    const FVector & V2
)

Public function Static

float

 

DistSquaredXY

(
    const FVector & V1,
    const FVector & V2
)

Squared distance between two points in the XY plane only.

Public function Static

float

 

DistXY

(
    const FVector & V1,
    const FVector & V2
)

Euclidean distance between two points in the XY plane (ignoring Z).

Public function Static

float

 

DotProduct

(
    const FVector & A,
    const FVector & B
)

Calculate the dot product of two vectors.

The dot product.

Public function

bool

 

Equals

(
    const FVector & V,
    float Tolerance
)

Check against another vector for equality, within specified error limits.

Public function Static

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

 

EvaluateBezier

(
    const FVector * ControlPoints,
    int32 NumPoints,
    TArray < FVector >& OutPoints
)

Generates a list of sample points on a Bezier curve defined by 2 points.

The path length.

Public function

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

 

FindBestAxisVectors

(
    FVector & Axis1,
    FVector & Axis2
)

Find good arbitrary axis vectors to represent U and V axes of a plane, using this vector as the normal of the plane.

Public function Static

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

 

GenerateClusterCenters

(
    TArray < FVector >& Clusters,
    const TArray < FVector >& Points,
    int32 NumIterations,
    int32 NumConnectionsToBeValid
)

Given a current set of cluster centers, a set of points, iterate N times to move clusters to be central.

Public function

FVector

 

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

 

GetAbsMin()

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

Public function

FVector

 

GetClampedToMaxSize

(
    float MaxSize
)

Create a copy of this vector, with its maximum magnitude clamped to MaxSize.

Public function

FVector

 

GetClampedToMaxSize2D

(
    float MaxSize
)

Create a copy of this vector, with the maximum 2D magnitude clamped to MaxSize. Z is unchanged.

Public function

FVector

 

GetClampedToSize

(
    float Min,
    float Max
)

Create a copy of this vector, with its magnitude clamped between Min and Max.

Public function

FVector

 

GetClampedToSize2D

(
    float Min,
    float Max
)

Create a copy of this vector, with the 2D magnitude clamped between Min and Max. Z is unchanged.

Public function

float

 

GetComponentForAxis

(
    EAxis::Type Axis
)

Get a specific component of the vector, given a specific axis by enum

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

FVector

 

GetSafeNormal

(
    float Tolerance
)

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

Public function

FVector

 

GetSafeNormal2D

(
    float Tolerance
)

Gets a normalized copy of the 2D components of the vector, checking it is safe to do so.

Public function

FVector

 

GetSignVector()

Get a copy of the vector as sign only.

Public function

FVector

 

GetUnsafeNormal()

Calculates normalized version of vector without checking for zero length.

Public function

FVector

 

GridSnap

(
    const float& GridSz
)

Gets a copy of this vector snapped to a grid.

A copy of this vector snapped to a grid.

Public function

float

 

HeadingAngle()

Convert a direction vector into a 'heading' angle.

Public function

bool

 

InitFromString

(
    const FString & InSourceString
)

Initialize this Vector based on an FString .

Public function

bool

 

IsNearlyZero

(
    float Tolerance
)

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

Public function

bool

 

IsNormalized()

Checks whether vector is normalized.

true if Normalized, false otherwise.

Public function

bool

 

IsUniform

(
    float Tolerance
)

Check whether X, Y and Z are nearly equal.

true if X == Y == Z within the specified tolerance.

Public function

bool

 

IsUnit

(
    float LengthSquaredTolerance
)

Check if the vector is of unit length, with specified tolerance.

Public function

bool

 

IsZero()

Checks whether all components of the vector are exactly zero.

Public function

FVector

 

MirrorByPlane

(
    const FPlane & Plane
)

Mirrors a vector about a plane.

Public function

FVector

 

MirrorByVector

(
    const FVector & MirrorNormal
)

Mirror a vector about a normal vector.

Mirrored vector.

Public function

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

 

NetSerialize

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

Network serialization function.

Public function

bool

 

Normalize

(
    float Tolerance
)

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

Public function Static

bool

 

Orthogonal

(
    const FVector & Normal1,
    const FVector & Normal2,
    float OrthogonalCosineThreshold
)

See if two normal vectors are nearly orthogonal (perpendicular), meaning the angle between them is close to 90 degrees.

Public function Static

bool

 

Parallel

(
    const FVector & Normal1,
    const FVector & Normal2,
    float ParallelCosineThreshold
)

See if two normal vectors are nearly parallel, meaning the angle between them is close to 0 degrees.

Public function Static

float

 

PointPlaneDist

(
    const FVector & Point,
    const FVector & PlaneBase,
    const FVector & PlaneNormal
)

Calculate the signed distance (in the direction of the normal) between a point and a plane.

Public function Static

FVector

 

PointPlaneProject

(
    const FVector & Point,
    const FVector & A,
    const FVector & B,
    const FVector & C
)

Calculate the projection of a point on the plane defined by counter-clockwise (CCW) points A,B,C.

Public function Static

FVector

 

PointPlaneProject

(
    const FVector & Point,
    const FPlane & Plane
)

Calculate the projection of a point on the given plane.

Projection of Point onto Plane

Public function Static

FVector

 

PointPlaneProject

(
    const FVector & Point,
    const FVector & PlaneBase,
    const FVector & PlaneNormal
)

Calculate the projection of a point on the plane defined by PlaneBase and PlaneNormal.

Public function Static

bool

 

PointsAreNear

(
    const FVector & Point1,
    const FVector & Point2,
    float Dist
)

Compare two points and see if they're within specified distance.

Public function Static

bool

 

PointsAreSame

(
    const FVector & P,
    const FVector & Q
)

Compare two points and see if they're the same, using a threshold.

Public function

FVector

 

Projection()

Projects 2D components of vector based on Z.

Projected version of vector based on Z.

Public function

FVector

 

ProjectOnTo

(
    const FVector & A
)

Gets a copy of this vector projected onto the input vector.

Projected vector.

Public function

FVector

 

ProjectOnToNormal

(
    const FVector & Normal
)

Gets a copy of this vector projected onto the input vector, which is assumed to be unit length.

Public function Static

FVector

 

RadiansToDegrees

(
    const FVector & RadVector
)

Converts a vector containing radian values to a vector containing degree values.

Public function

FVector

 

Reciprocal()

Gets the reciprocal of this vector, avoiding division by zero.

Public function

FVector

 

RotateAngleAxis

(
    const float AngleDeg,
    const FVector & Axis
)

Rotates around Axis (assumes Axis.Size() == 1).

Rotated Vector.

Public function

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

 

Rotation()

Return the FRotator orientation corresponding to the direction in which the vector points.

Public function

FVector

 

SafeNormal

(
    float Tolerance
)

Public function

FVector

 

SafeNormal2D

(
    float Tolerance
)

Public function

bool

 

Serialize

(
    FArchive & Ar
)

Public function

void

 

Set

(
    float InX,
    float InY,
    float InZ
)

Simple functions.

Public function

void

 

SetComponentForAxis

(
    EAxis::Type Axis,
    float Component
)

Set a specified componet of the vector, given a specific axis by enum

Public function

float

 

Size()

Get the length (magnitude) of this vector.

The length of this vector.

Public function

float

 

Size2D()

Get the length of the 2D components of this vector.

The 2D length of this vector.

Public function

float

 

SizeSquared()

Get the squared length of this vector.

The squared length of this vector.

Public function

float

 

SizeSquared2D()

Get the squared length of the 2D components of this vector.

Public function

FString

 

ToCompactString()

Get a short textural representation of this vector, for compact readable logging.

Public function

FText

 

ToCompactText()

Get a short locale aware textural representation of this vector, for compact readable logging.

Public function

void

 

ToDirectionAndLength

(
    FVector & OutDir,
    float& OutLength
)

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

Public function

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

 

ToOrientationQuat()

Return the Quaternion orientation corresponding to the direction in which the vector points.

Public function

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

 

ToOrientationRotator()

Return the FRotator orientation corresponding to the direction in which the vector points.

Public function

FString

 

ToString()

Get a textual representation of this vector.

A string describing the vector.

Public function

FText

 

ToText()

Get a locale aware textual representation of this vector.

A string describing the vector.

Public function Static

float

 

Triple

(
    const FVector & X,
    const FVector & Y,
    const FVector & Z
)

Triple product of three vectors: X dot (Y cross Z).

The triple product: X dot (Y cross Z).

Public function

FVector2D

 

UnitCartesianToSpherical()

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

Public function

FVector

 

UnsafeNormal()

Public function

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

 

UnwindEuler()

When this vector contains Euler angles (degrees), ensure that angles are between +/-180

Public function Static

FVector

 

VectorPlaneProject

(
    const FVector & V,
    const FVector & PlaneNormal
)

Calculate the projection of a vector on the plane defined by PlaneNormal.

Operators

Name Description

Public function

FVector

 

operator-()

Get a negated copy of the vector.

A negated copy of the vector.

Public function

FVector

 

operator-

(
    const FVector & V
)

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

Public function

FVector

 

operator-

(
    float Bias
)

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

The result of subtraction.

Public function

bool

 

operator!=

(
    const FVector & V
)

Check against another vector for inequality.

true if the vectors are not equal, false otherwise.

Public function

FVector

 

operator*

(
    float Scale
)

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

Public function

FVector

 

operator*

(
    const FVector & V
)

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

Public function

FVector

 

operator*=

(
    float Scale
)

Scales the vector.

Copy of the vector after scaling.

Public function

FVector

 

operator*=

(
    const FVector & V
)

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

Public function

FVector

 

operator/

(
    float Scale
)

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

The result of division.

Public function

FVector

 

operator/

(
    const FVector & V
)

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

The result of division.

Public function

FVector

 

operator/=

(
    float V
)

Divides the vector by a number.

Copy of the vector after division.

Public function

FVector

 

operator/=

(
    const FVector & V
)

Divides the 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 the component.

Public function

FVector

 

operator^

(
    const FVector & V
)

Calculate cross product between this and another vector.

The cross product.

Public function

float

 

operator|

(
    const FVector & V
)

Calculate the dot product between this and another vector.

The dot product.

Public function

FVector

 

operator+

(
    const FVector & V
)

Gets the result of component-wise addition of this and another vector.

Public function

FVector

 

operator+

(
    float Bias
)

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

The result of addition.

Public function

FVector

 

operator+=

(
    const FVector & V
)

Adds another vector to this. Uses component-wise addition.

Copy of the vector after addition.

Public function

FVector

 

operator-=

(
    const FVector & V
)

Subtracts another vector from this.

Public function

bool

 

operator==

(
    const FVector & V
)

Binary comparison operators.

Constants

Name

Description

ForwardVector

Unreal forward vector (1,0,0)

OneVector

One vector (1,1,1)

RightVector

Unreal right vector (0,1,0)

UpVector

World up vector (0,0,1)

ZeroVector

A zero vector (0,0,0)

References

Module

Core

Header

Runtime/Core/Public/Math/Vector.h