Navigation
API > API/Runtime > API/Runtime/Core
A vector in 3-D space composed of components (X, Y, Z) with floating point precision.
| Name | TVector |
| Type | struct |
| Header File | /Engine/Source/Runtime/Core/Public/Math/MathFwd.h |
| Include Path | #include "Math/MathFwd.h" |
| Source | /Engine/Source/Runtime/Core/Public/Math/Vector.h |
Syntax
template<typename T>
struct TVector
Derived Classes
TVector derived class hierarchy
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TVector
(
const FLinearColor& InColor |
Constructs a vector from an FLinearColor. | Math/Vector.h | |
TVector
(
TIntVector3< IntType > InVector |
Constructs a vector from an FIntVector. | Math/Vector.h | |
| Constructs a vector from an FIntPoint. | Math/Vector.h | ||
TVector
(
EForceInit |
Constructor which initializes all components to zero. | Math/Vector.h | |
TVector
(
const UE::Math::TVector4< T >& V |
Constructor using the XYZ components from a 4D vector.FVector inline functions | Math/Vector.h | |
| Conversion from other type. | Math/Vector.h | ||
constexpr TVector
(
T InF, |
Math/Vector.h | ||
TVector
(
T InF |
Constructor initializing all components to a single T value. | Math/Vector.h | |
TVector
(
T InX, |
Constructor using initial values for each component. | Math/Vector.h | |
| Constructs a vector from an TVector2 |
Math/Vector.h | ||
TVector () |
Default constructor (no initialization). | Math/Vector.h |
Class Specializations
| Name | Remarks |
|---|---|
| TVector< FReal, 4 > | |
| TVector< FRealDouble, 2 > | |
| TVector< FRealDouble, 3 > | |
| TVector< FRealSingle, 2 > | |
| TVector< FRealSingle, 3 > | |
| TVector< int32, 2 > | |
| TVector< T, 3 > |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| FReal | T | Math/Vector.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| BackwardVector | const TVector< T > | Unreal backward vector (-1,0,0) | Math/Vector.h |
| DownVector | const TVector< T > | Unreal down vector (0,0,-1) | Math/Vector.h |
| ForwardVector | const TVector< T > | Unreal forward vector (1,0,0) | Math/Vector.h |
| LeftVector | const TVector< T > | Unreal left vector (0,-1,0) | Math/Vector.h |
| NumComponents | int32 | The number of components this vector type has. | Math/Vector.h |
| OneVector | const TVector< T > | One vector (1,1,1) | Math/Vector.h |
| RightVector | const TVector< T > | Unreal right vector (0,1,0) | Math/Vector.h |
| UpVector | const TVector< T > | Unreal up vector (0,0,1) | Math/Vector.h |
| XAxisVector | const TVector< T > | Unit X axis vector (1,0,0) | Math/Vector.h |
| YAxisVector | const TVector< T > | Unit Y axis vector (0,1,0) | Math/Vector.h |
| ZAxisVector | const TVector< T > | Unit Z axis vector (0,0,1) | Math/Vector.h |
| ZeroVector | const TVector< T > | A zero vector (0,0,0) | Math/Vector.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| TVector | union UE::Math::TVector | Math/Vector.h | ||
| X | T | Vector's X component. | Math/Vector.h | |
| XYZ | T | Math/Vector.h | ||
| Y | T | Vector's Y component. | Math/Vector.h | |
| Z | T | Vector's Z component. | Math/Vector.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void AddBounded
(
const TVector< T >& V, |
Add a vector to this and clamp the result in a cube. | Math/Vector.h | |
bool AllComponentsEqual
(
T Tolerance |
Checks whether all components of this vector are the same, within a tolerance. | Math/Vector.h | |
| Get a copy of this vector, clamped inside of a cube. | Math/Vector.h | ||
TVector< T > BoundToCube
(
T Radius |
Get a copy of this vector, clamped inside of a cube. | Math/Vector.h | |
T Component
(
int32 Index |
Gets a specific component of the vector. | Math/Vector.h | |
T & Component
(
int32 Index |
Gets a specific component of the vector. | Math/Vector.h | |
| Gets the component-wise max of two vectors. | Math/Vector.h | ||
| Gets the component-wise min of two vectors. | Math/Vector.h | ||
bool ContainsNaN() |
Utility to check if there are any non-finite values (NaN or Inf) in this vector. | Math/Vector.h | |
T CosineAngle2D
(
TVector< T > B |
Returns the cosine of the angle between this vector and another projected onto the XY plane (no Z). | Math/Vector.h | |
| Calculate cross product between this and another vector. | Math/Vector.h | ||
void DiagnosticCheckNaN () |
Math/Vector.h | ||
void DiagnosticCheckNaN
(
const TCHAR* Message |
Math/Vector.h | ||
T Dot
(
const TVector< T >& V |
Calculate the dot product between this and another vector. | Math/Vector.h | |
bool Equals
(
const TVector< T >& V, |
Check against another vector for equality, within specified error limits. | Math/Vector.h | |
| Find good arbitrary axis vectors to represent U and V axes of a plane, using this vector as the normal of the plane. | Math/Vector.h | ||
TVector< T > GetAbs() |
Get a copy of this vector with absolute value of each component. | Math/Vector.h | |
T GetAbsMax() |
Get the maximum absolute value of the vector's components. | Math/Vector.h | |
T GetAbsMin() |
Get the minimum absolute value of the vector's components. | Math/Vector.h | |
TVector< T > GetClampedToMaxSize
(
T MaxSize |
Create a copy of this vector, with its maximum magnitude clamped to MaxSize. | Math/Vector.h | |
TVector< T > GetClampedToMaxSize2D
(
T MaxSize |
Create a copy of this vector, with the maximum 2D magnitude clamped to MaxSize. Z is unchanged. | Math/Vector.h | |
TVector< T > GetClampedToSize
(
T Min, |
Create a copy of this vector, with its magnitude clamped between Min and Max. | Math/Vector.h | |
TVector< T > GetClampedToSize2D
(
T Min, |
Create a copy of this vector, with the 2D magnitude clamped between Min and Max. Z is unchanged. | Math/Vector.h | |
T GetComponentForAxis
(
EAxis::Type Axis |
Get a specific component of the vector, given a specific axis by enum | Math/Vector.h | |
T GetMax() |
Get the maximum value of the vector's components. | Math/Vector.h | |
T GetMin() |
Get the minimum value of the vector's components. | Math/Vector.h | |
TVector< T > GetSafeNormal
(
T Tolerance, |
Gets a normalized copy of the vector, checking it is safe to do so based on the length. | Math/Vector.h | |
TVector< T > GetSafeNormal2D
(
T Tolerance, |
Gets a normalized copy of the 2D components of the vector, checking it is safe to do so. | Math/Vector.h | |
TVector< T > GetSignVector () |
Get a copy of the vector as sign only. | Math/Vector.h | |
TVector< T > GetUnsafeNormal () |
Calculates normalized version of vector without checking for zero length. | Math/Vector.h | |
TVector< T > GetUnsafeNormal2D () |
Calculates normalized 2D version of vector without checking for zero length. | Math/Vector.h | |
| Gets a copy of this vector snapped to a grid. | Math/Vector.h | ||
T HeadingAngle() |
Convert a direction vector into a 'heading' angle. | Math/Vector.h | |
bool InitFromCompactString
(
const FString& InSourceString |
Initialize this Vector based on an FString. | Math/Vector.h | |
bool InitFromString
(
const FString& InSourceString |
Initialize this Vector based on an FString. | Math/Vector.h | |
bool IsNearlyZero
(
T Tolerance |
Checks whether vector is near to zero within a specified tolerance. | Math/Vector.h | |
bool IsNormalized() |
Checks whether vector is normalized. | Math/Vector.h | |
bool IsUniform
(
T Tolerance |
Check whether X, Y and Z are nearly equal. | Math/Vector.h | |
bool IsUnit
(
T LengthSquaredTolerance |
Check if the vector is of unit length, with specified tolerance. | Math/Vector.h | |
bool IsValidIndex
(
int32 Index |
Tests if index is valid, i.e. greater than or equal to zero, and less than the number of components in the vector. | Math/Vector.h | |
bool IsZero() |
Checks whether all components of the vector are exactly zero. | Math/Vector.h | |
T Length() |
Get the length (magnitude) of this vector. | Math/Vector.h | |
| Mirrors a vector about a plane.TVector inline functions | Math/Vector.h | ||
| Mirror a vector about a normal vector. | Math/Vector.h | ||
bool NetSerialize
(
FArchive& Ar, |
Network serialization function. | Math/Vector.h | |
bool Normalize
(
T Tolerance |
Normalize this vector in-place if it is larger than a given tolerance. Leaves it unchanged if not. | Math/Vector.h | |
TVector< T > Projection() |
Projects 2D components of vector based on Z. | Math/Vector.h | |
| Gets a copy of this vector projected onto the input vector. | Math/Vector.h | ||
| Gets a copy of this vector projected onto the input vector, which is assumed to be unit length. | Math/Vector.h | ||
TVector< T > Reciprocal () |
Gets the reciprocal of this vector, avoiding division by zero. | Math/Vector.h | |
| Rotates around Axis (assumes Axis.Size() == 1). | Math/Vector.h | ||
| Rotates around Axis (assumes Axis.Size() == 1). | Math/Vector.h | ||
UE::Math::TRotator< T > Rotation () |
Return the UE::Math::TRotator |
Math/Vector.h | |
bool Serialize
(
FStructuredArchive::FSlot Slot |
Math/Vector.h | ||
| Math/Vector.h | |||
bool SerializeFromMismatchedTag
(
FName StructTag, |
Math/Vector.h | ||
void Set
(
T InX, |
Set the values of the vector directly. | Math/Vector.h | |
void SetComponentForAxis
(
EAxis::Type Axis, |
Set a specified componet of the vector, given a specific axis by enum | Math/Vector.h | |
T Size() |
Get the length (magnitude) of this vector. | Math/Vector.h | |
T Size2D() |
Get the length of the 2D components of this vector. | Math/Vector.h | |
T SizeSquared() |
Get the squared length of this vector. | Math/Vector.h | |
T SizeSquared2D() |
Get the squared length of the 2D components of this vector. | Math/Vector.h | |
T SquaredLength() |
Get the squared length of this vector. | Math/Vector.h | |
FString ToCompactString() |
Get a short textural representation of this vector, for compact readable logging. | Math/Vector.h | |
FText ToCompactText() |
Get a short locale aware textural representation of this vector, for compact readable logging. | Math/Vector.h | |
void ToDirectionAndLength
(
TVector< T >& OutDir, |
Util to convert this vector into a unit direction vector and its original length. | Math/Vector.h | |
void ToDirectionAndLength
(
TVector< T >& OutDir, |
Math/Vector.h | ||
TQuat< T > ToOrientationQuat () |
Return the Quaternion orientation corresponding to the direction in which the vector points. | Math/Vector.h | |
TRotator< T > ToOrientationRotator () |
Return the TRotator orientation corresponding to the direction in which the vector points. | Math/Vector.h | |
FString ToString() |
Get a textual representation of this vector. | Math/Vector.h | |
FText ToText() |
Get a locale aware textual representation of this vector. | Math/Vector.h | |
TVector2< T > UnitCartesianToSpherical() |
Converts a Cartesian unit vector into spherical coordinates on the unit sphere. | Math/Vector.h | |
void UnwindEuler() |
When this vector contains Euler angles (degrees), ensure that angles are between +/-180 | Math/Vector.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Compute pushout of a box from a plane. | Math/Vector.h | ||
| See if two normal vectors are coincident (nearly parallel and point in the same direction). | Math/Vector.h | ||
| See if two planes are coplanar. | Math/Vector.h | ||
static void CreateOrthonormalBasis
(
TVector< T >& XAxis, |
Create an orthonormal basis from a basis with at least two orthogonal vectors. | Math/Vector.h | |
| Calculate the cross product of two vectors. | Math/Vector.h | ||
| Converts a vector containing degree values to a vector containing radian values. | Math/Vector.h | ||
| Euclidean distance between two points. | Math/Vector.h | ||
| Math/Vector.h | |||
| Math/Vector.h | |||
| Squared distance between two points. | Math/Vector.h | ||
| Math/Vector.h | |||
| Squared distance between two points in the XY plane only. | Math/Vector.h | ||
| Euclidean distance between two points in the XY plane (ignoring Z). | Math/Vector.h | ||
| Calculate the dot product of two vectors. | Math/Vector.h | ||
| Generates a list of sample points on a Bezier curve defined by 2 points. | Math/Vector.h | ||
| Given a current set of cluster centers, a set of points, iterate N times to move clusters to be central. | Math/Vector.h | ||
| Math/Vector.h | |||
| Math/Vector.h | |||
| Min, Max, Min3, Max3 like FMath | Math/Vector.h | ||
| Math/Vector.h | |||
static TVector< T > One() |
Math/Vector.h | ||
| See if two normal vectors are nearly orthogonal (perpendicular), meaning the angle between them is close to 90 degrees. | Math/Vector.h | ||
| See if two normal vectors are nearly parallel, meaning the angle between them is close to 0 degrees. | Math/Vector.h | ||
| Calculate the signed distance (in the direction of the normal) between a point and a plane. | Math/Vector.h | ||
| Calculate the projection of a point on the plane defined by counter-clockwise (CCW) points A,B,C. | Math/Vector.h | ||
static TVector< T > PointPlaneProject
(
const TVector< T >& Point, |
Calculate the projection of a point on the plane defined by PlaneBase and PlaneNormal. | Math/Vector.h | |
static TVector< T > PointPlaneProject
(
const TVector< T >& Point, |
Calculate the projection of a point on the given plane. | Math/Vector.h | |
| Compare two points and see if they're within specified distance. | Math/Vector.h | ||
| Compare two points and see if they're the same, using a threshold. | Math/Vector.h | ||
| Converts a vector containing radian values to a vector containing degree values. | Math/Vector.h | ||
| Interpolate from normalized vector A to normalized vector B along a spherical path. | Math/Vector.h | ||
| Interpolate from a vector to the direction of another vector along a spherical path. | Math/Vector.h | ||
| Triple product of three vectors: X dot (Y cross Z). | Math/Vector.h | ||
static TVector< T > UnitX() |
Math/Vector.h | ||
static TVector< T > UnitY() |
Math/Vector.h | ||
static TVector< T > UnitZ() |
Math/Vector.h | ||
| Calculate the projection of a vector on the plane defined by PlaneNormal. | Math/Vector.h | ||
static TVector< T > Zero() |
Math/Vector.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Gets the result of subtracting from each component of the vector. | Math/Vector.h | ||
| Gets the result of component-wise subtraction of this by another vector. | Math/Vector.h | ||
TVector< T > operator-() |
Get a negated copy of the vector. | Math/Vector.h | |
bool operator!=
(
const TVector< T >& V |
Check against another vector for inequality. | Math/Vector.h | |
| Gets the result of component-wise multiplication of this vector by another. | Math/Vector.h | ||
| Gets the result of scaling the vector (multiplying each component by a value). | Math/Vector.h | ||
TVector< T > operator*=
(
const TVector< T >& V |
Multiplies the vector with another vector, using component-wise multiplication. | Math/Vector.h | |
TVector< T > operator*=
(
FArg Scale |
Scales the vector. | Math/Vector.h | |
| Gets the result of component-wise division of this vector by another. | Math/Vector.h | ||
| Gets the result of dividing each component of the vector by a value. | Math/Vector.h | ||
TVector< T > operator/=
(
const TVector< T >& V |
Divides the vector by another vector, using component-wise division. | Math/Vector.h | |
TVector< T > operator/=
(
FArg Scale |
Divides the vector by a number. | Math/Vector.h | |
T operator[]
(
int32 Index |
Gets specific component of the vector. | Math/Vector.h | |
T & operator[]
(
int32 Index |
Gets specific component of the vector. | Math/Vector.h | |
| Calculate cross product between this and another vector. | Math/Vector.h | ||
T operator|
(
const TVector< T >& V |
Calculate the dot product between this and another vector. | Math/Vector.h | |
| Gets the result of adding to each component of the vector. | Math/Vector.h | ||
| Gets the result of component-wise addition of this and another vector. | Math/Vector.h | ||
| Adds another vector to this. Uses component-wise addition. | Math/Vector.h | ||
| Subtracts another vector from this. Uses component-wise subtraction. | Math/Vector.h | ||
bool operator==
(
const TVector< T >& V |
Check against another vector for equality. | Math/Vector.h |