![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <Vector2D.h>
Public Types | |
| using | FReal = T |
Static Public Member Functions | |
| static TVector2< T > | Zero () |
| static TVector2< T > | One () |
| static TVector2< T > | UnitX () |
| static TVector2< T > | UnitY () |
| static UE_FORCEINLINE_HINT T | DotProduct (const TVector2< T > &A, const TVector2< T > &B) |
| static UE_FORCEINLINE_HINT T | DistSquared (const TVector2< T > &V1, const TVector2< T > &V2) |
| static UE_FORCEINLINE_HINT T | Distance (const TVector2< T > &V1, const TVector2< T > &V2) |
| static UE_FORCEINLINE_HINT T | CrossProduct (const TVector2< T > &A, const TVector2< T > &B) |
| static UE_FORCEINLINE_HINT TVector2< T > | Max (const TVector2< T > &A, const TVector2< T > &B) |
| static UE_FORCEINLINE_HINT TVector2< T > | Min (const TVector2< T > &A, const TVector2< T > &B) |
| static UE_FORCEINLINE_HINT TVector2< T > | Clamp (const TVector2< T > &V, const TVector2< T > &MinValue, const TVector2< T > &MaxValue) |
Public Attributes | ||
| union { | ||
| struct { | ||
| T X | ||
| T Y | ||
| } | ||
| T XY [2] | ||
| }; | ||
Static Public Attributes | |
| static constexpr int32 | NumComponents = 2 |
| static CORE_API const TVector2< T > | ZeroVector |
| static CORE_API const TVector2< T > | UnitVector |
| static CORE_API const TVector2< T > | Unit45Deg |
| using UE::Math::TVector2< T >::FReal = T |
|
default |
Default constructor (no initialization).
| UE_FORCEINLINE_HINT UE::Math::TVector2< T >::TVector2 | ( | T | InX, |
| T | InY | ||
| ) |
Constructor using initial values for each component.
| InX | X coordinate. |
| InY | Y coordinate. |
|
explicit |
Constructor initializing both components to a single T value.
| InF | Value to set both components to. |
| UE_FORCEINLINE_HINT UE::Math::TVector2< T >::TVector2 | ( | TIntPoint< IntType > | InPos | ) |
Constructs a vector from an FIntPoint.
| InPos | Integer point used to set this vector. |
|
inlineexplicit |
|
explicit |
Constructor which initializes all components to zero.
| EForceInit | Force init enum |
|
inlineexplicit |
Constructor that does not initialize. More explicit than the default constructor.
| ENoInit | Don't init |
|
inlineexplicit |
Constructs a vector from an FVector. Copies the X and Y components from the FVector.
| V | Vector to copy from. |
|
inlineexplicit |
Constructs a vector from an FVector4. Copies the X and Y components from the FVector4.
| V | Vector to copy from. |
|
inlineexplicit |
|
inline |
|
static |
Returns a vector with each component clamped between a minimum and a maximum.
| V | The vector to clamp. |
| MinValue | The minimum vector. |
| MaxValue | The maximum vector. |
| UE_FORCEINLINE_HINT TVector2< T > UE::Math::TVector2< T >::ClampAxes | ( | T | MinAxisVal, |
| T | MaxAxisVal | ||
| ) | const |
Creates a copy of this vector with both axes clamped to the given range.
|
inline |
Gets a specific component of the vector.
| Index | The index of the component required. |
|
inline |
Gets a specific component of the vector.
| Index | The index of the component required. |
| UE_FORCEINLINE_HINT TVector2< T > UE::Math::TVector2< T >::ComponentMax | ( | const TVector2< T > & | Other | ) | const |
Gets the component-wise max of two vectors.
| UE_FORCEINLINE_HINT TVector2< T > UE::Math::TVector2< T >::ComponentMin | ( | const TVector2< T > & | Other | ) | const |
Gets the component-wise min of two vectors.
| UE_FORCEINLINE_HINT bool UE::Math::TVector2< T >::ComponentwiseAllGreaterOrEqual | ( | const TVector2< T > & | Other | ) | const |
Checks whether both components of this vector are greater than or equal to another.
| Other | The vector to compare against. |
| UE_FORCEINLINE_HINT bool UE::Math::TVector2< T >::ComponentwiseAllGreaterThan | ( | const TVector2< T > & | Other | ) | const |
Checks whether both components of this vector are greater than another.
| Other | The vector to compare against. |
| UE_FORCEINLINE_HINT bool UE::Math::TVector2< T >::ComponentwiseAllLessOrEqual | ( | const TVector2< T > & | Other | ) | const |
Checks whether both components of this vector are less than or equal to another.
| Other | The vector to compare against. |
| UE_FORCEINLINE_HINT bool UE::Math::TVector2< T >::ComponentwiseAllLessThan | ( | const TVector2< T > & | Other | ) | const |
Checks whether both components of this vector are less than another.
| Other | The vector to compare against. |
|
inline |
Utility to check if there are any non-finite values (NaN or Inf) in this vector.
|
static |
Calculate the cross product of two vectors.
| A | The first vector. |
| B | The second vector. |
|
inline |
|
static |
Distance between two 2D points.
| V1 | The first point. |
| V2 | The second point. |
|
static |
Squared distance between two 2D points.
| V1 | The first point. |
| V2 | The second point. |
| UE_FORCEINLINE_HINT T UE::Math::TVector2< T >::Dot | ( | const TVector2< T > & | V2 | ) | const |
Get the dot product of this vector against another.
| V2 | The vector to measure dot product against. |
|
static |
Calculates the dot product of two vectors.
| A | The first vector. |
| B | The second vector. |
| UE_FORCEINLINE_HINT bool UE::Math::TVector2< T >::Equals | ( | const TVector2< T > & | V, |
| T | Tolerance = UE_KINDA_SMALL_NUMBER |
||
| ) | const |
Checks for equality with error-tolerant comparison.
| V | The vector to compare. |
| Tolerance | Error tolerance. |
| UE_FORCEINLINE_HINT TVector2< T > UE::Math::TVector2< T >::GetAbs | ( | ) | const |
Get a copy of this vector with absolute value of each component.
| UE_FORCEINLINE_HINT T UE::Math::TVector2< T >::GetAbsMax | ( | ) | const |
Get the maximum absolute value of the vector's components.
|
inline |
Create a copy of this vector, with its maximum magnitude clamped to MaxSize.
|
inline |
Create a copy of this vector, with its magnitude clamped between Min and Max.
| UE_FORCEINLINE_HINT T UE::Math::TVector2< T >::GetMax | ( | ) | const |
Get the maximum value of the vector's components.
| UE_FORCEINLINE_HINT T UE::Math::TVector2< T >::GetMin | ( | ) | const |
Get the minimum value of the vector's components.
|
inline |
Rotates around axis (0,0,1)
| AngleDeg | Angle to rotate (in degrees) |
|
inline |
Gets a normalized copy of the vector, checking it is safe to do so based on the length. Returns zero vector if vector length is too small to safely normalize.
| Tolerance | Minimum squared length of vector for normalization. |
|
inline |
Get a copy of the vector as sign only. Each component is set to +1 or -1, with the sign of zero treated as +1.
| A | copy of the vector with each component set to +1 or -1 |
|
inline |
Initialize this Vector based on an FString. The String is expected to contain X=, Y=. The TVector2<T> will be bogus when InitFromString returns false.
| InSourceString | FString containing the vector values. |
|
inline |
Get this vector as an Int Point.
|
inline |
Checks whether vector is near to zero within a specified tolerance.
| Tolerance | Error tolerance. |
| bool UE::Math::TVector2< T >::IsValidIndex | ( | int32 | Index | ) | const |
Tests if index is valid, i.e. greater than or equal to zero, and less than the number of components in the vector.
| Index | Index to test. |
| UE_FORCEINLINE_HINT bool UE::Math::TVector2< T >::IsZero | ( | ) | const |
Checks whether all components of the vector are exactly zero.
|
inline |
|
static |
Returns a vector with the maximum component for each dimension from the pair of vectors.
| A | The first vector. |
| B | The second vector. |
|
static |
Returns a vector with the minimum component for each dimension from the pair of vectors.
| A | The first vector. |
| B | The second vector. |
|
inline |
Network serialization function. FVectors NetSerialize without quantization (ie exact values are serialized).
|
inline |
Normalize this vector in-place if it is large enough, set it to (0,0) otherwise. (Note this is different from TVector<>::Normalize, which leaves the vector unchanged if it is too small to normalize.)
| Tolerance | Minimum squared length of vector for normalization. |
|
inlinestatic |
| UE_FORCEINLINE_HINT bool UE::Math::TVector2< T >::operator!= | ( | const TVector2< T > & | V | ) | const |
Compares this vector against another for inequality.
| V | The vector to compare against. |
| UE_FORCEINLINE_HINT TVector2< T > UE::Math::TVector2< T >::operator* | ( | const TVector2< T > & | V | ) | const |
Gets the result of component-wise multiplication of this vector by another.
| V | The other vector to multiply this by. |
| UE_FORCEINLINE_HINT TVector2< T > UE::Math::TVector2< T >::operator* | ( | T | Scale | ) | const |
Gets the result of scaling the vector (multiplying each component by a value).
| Scale | How much to scale the vector by. |
|
inline |
Multiplies this vector with another vector, using component-wise multiplication.
| V | The vector to multiply with. |
|
inline |
Scales this vector.
| Scale | The scale to multiply vector by. |
| UE_FORCEINLINE_HINT TVector2< T > UE::Math::TVector2< T >::operator+ | ( | const TVector2< T > & | V | ) | const |
Gets the result of adding two vectors together.
| V | The other vector to add to this. |
| UE_FORCEINLINE_HINT TVector2< T > UE::Math::TVector2< T >::operator+ | ( | T | A | ) | const |
Gets the result of adding A to each component of the vector.
| A | T to add to each component. |
|
inline |
Adds another vector to this.
| V | The other vector to add. |
| UE_FORCEINLINE_HINT TVector2< T > UE::Math::TVector2< T >::operator- | ( | ) | const |
Gets a negated copy of the vector.
| UE_FORCEINLINE_HINT TVector2< T > UE::Math::TVector2< T >::operator- | ( | const TVector2< T > & | V | ) | const |
Gets the result of subtracting a vector from this one.
| V | The other vector to subtract from this. |
| UE_FORCEINLINE_HINT TVector2< T > UE::Math::TVector2< T >::operator- | ( | T | A | ) | const |
Gets the result of subtracting A from each component of the vector.
| A | T to subtract from each component |
|
inline |
Subtracts another vector from this.
| V | The other vector to subtract. |
| UE_FORCEINLINE_HINT TVector2< T > UE::Math::TVector2< T >::operator/ | ( | const TVector2< T > & | V | ) | const |
Gets the result of component-wise division of this vector by another.
| V | The other vector to divide this by. |
|
inline |
Gets the result of dividing each component of the vector by a value.
| Scale | How much to divide the vector by. |
|
inline |
Divides this vector by another vector, using component-wise division.
| V | The vector to divide by. |
|
inline |
Divides this vector.
| V | What to divide vector by. |
| UE_FORCEINLINE_HINT bool UE::Math::TVector2< T >::operator== | ( | const TVector2< T > & | V | ) | const |
Compares this vector against another for equality.
| V | The vector to compare against. |
| UE_FORCEINLINE_HINT T & UE::Math::TVector2< T >::operator[] | ( | int32 | Index | ) |
Gets specific component of the vector.
| Index | the index of vector component |
| UE_FORCEINLINE_HINT T UE::Math::TVector2< T >::operator[] | ( | int32 | Index | ) | const |
Gets specific component of the vector.
| Index | the index of vector component |
| UE_FORCEINLINE_HINT T UE::Math::TVector2< T >::operator^ | ( | const TVector2< T > & | V | ) | const |
Calculates cross product of this vector and another.
| V | The other vector. |
| UE_FORCEINLINE_HINT T UE::Math::TVector2< T >::operator| | ( | const TVector2< T > & | V | ) | const |
Calculates dot product of this vector and another.
| V | The other vector. |
|
inline |
Get this vector as a vector where each component has been rounded to the nearest int.
|
inline |
|
inline |
|
inline |
|
inline |
Set the values of the vector directly.
| InX | New X coordinate. |
| InY | New Y coordinate. |
| UE_FORCEINLINE_HINT T UE::Math::TVector2< T >::Size | ( | ) | const |
| UE_FORCEINLINE_HINT T UE::Math::TVector2< T >::SizeSquared | ( | ) | const |
Get the squared length of this vector.
|
inline |
Converts spherical coordinates on the unit sphere into a Cartesian unit length vector.
|
inline |
Get the squared length of this vector.
|
inline |
|
inline |
Util to convert this vector into a unit direction vector and its original length.
| OutDir | Reference passed in to store unit direction vector. |
| OutLength | Reference passed in to store length of the vector. |
| UE_FORCEINLINE_HINT FString UE::Math::TVector2< T >::ToString | ( | ) | const |
Get a textual representation of the vector.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
| union { ... } UE::Math::TVector2< T > |
|
staticconstexpr |
The number of components this vector type has.
|
static |
Global 2D unit vector constant along the 45 degree angle or symmetrical positive axes (sqrt(.5),sqrt(.5)) or (.707,.707). https://en.wikipedia.org/wiki/Unit_vector
UnitVector above is actually a value with axes of 1 rather than a magnitude of one.
|
static |
Global 2D one vector (poorly named) constant (1,1).
Unit45Deg below for an actual unit vector. | T UE::Math::TVector2< T >::X |
Vector's X component.
| T UE::Math::TVector2< T >::XY[2] |
| T UE::Math::TVector2< T >::Y |
Vector's Y component.
|
static |
Global 2D zero vector constant (0,0)