![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <Vector.h>
Inheritance diagram for UE::Math::TVector< T >:Public Types | |
| using | FReal = T |
Public Attributes | ||
| union { | ||
| struct { | ||
| T X | ||
| T Y | ||
| T Z | ||
| } | ||
| T XYZ [3] | ||
| }; | ||
Static Public Attributes | |
| static constexpr int32 | NumComponents = 3 |
| static CORE_API const TVector< T > | ZeroVector |
| static CORE_API const TVector< T > | OneVector |
| static CORE_API const TVector< T > | UpVector |
| static CORE_API const TVector< T > | DownVector |
| static CORE_API const TVector< T > | ForwardVector |
| static CORE_API const TVector< T > | BackwardVector |
| static CORE_API const TVector< T > | RightVector |
| static CORE_API const TVector< T > | LeftVector |
| static CORE_API const TVector< T > | XAxisVector |
| static CORE_API const TVector< T > | YAxisVector |
| static CORE_API const TVector< T > | ZAxisVector |
A vector in 3-D space composed of components (X, Y, Z) with floating point precision.
| using UE::Math::TVector< T >::FReal = T |
|
default |
Default constructor (no initialization).
|
inlineexplicit |
Constructor initializing all components to a single T value.
| InF | Value to set all components to. |
|
constexpr |
|
inline |
Constructor using initial values for each component.
| InX | X Coordinate. |
| InY | Y Coordinate. |
| InZ | Z Coordinate. |
|
inlineexplicit |
Constructs a vector from an TVector2<T> and Z value.
| V | Vector to copy from. |
| InZ | Z Coordinate. |
|
inline |
Constructor using the XYZ components from a 4D vector.
| V | 4D Vector to copy from. |
|
inlineexplicit |
Constructs a vector from an FLinearColor.
| InColor | Color to copy from. |
|
inlineexplicit |
Constructs a vector from an FIntVector.
| InVector | FIntVector to copy from. |
|
inlineexplicit |
Constructs a vector from an FIntPoint.
| A | Int Point used to set X and Y coordinates, Z is set to zero. |
|
inlineexplicit |
Constructor which initializes all components to zero.
| EForceInit | Force init enum |
|
inlineexplicit |
| UE_FORCEINLINE_HINT void UE::Math::TVector< T >::AddBounded | ( | const TVector< T > & | V, |
| T | Radius = MAX_int16 |
||
| ) |
Add a vector to this and clamp the result in a cube.
| V | Vector to add. |
| Radius | Half size of the cube. |
| UE_FORCEINLINE_HINT bool UE::Math::TVector< T >::AllComponentsEqual | ( | T | Tolerance = UE_KINDA_SMALL_NUMBER | ) | const |
Checks whether all components of this vector are the same, within a tolerance.
| Tolerance | Error tolerance. |
|
inline |
Get a copy of this vector, clamped inside of a cube.
|
inline |
Get a copy of this vector, clamped inside of a cube.
| Radius | Half size of the cube. |
|
static |
Compute pushout of a box from a plane.
| Normal | The plane normal. |
| Size | The size of the box. |
|
inlinestatic |
See if two normal vectors are coincident (nearly parallel and point in the same direction).
| Normal1 | First normalized vector. |
| Normal2 | Second normalized vector. |
| ParallelCosineThreshold | Normals are coincident if dot product (cosine of angle between them) is greater than or equal to this. For example: cos(1.0 degrees). |
|
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 TVector< T > UE::Math::TVector< T >::ComponentMax | ( | const TVector< T > & | Other | ) | const |
Gets the component-wise max of two vectors.
| UE_FORCEINLINE_HINT TVector< T > UE::Math::TVector< T >::ComponentMin | ( | const TVector< T > & | Other | ) | const |
Gets the component-wise min of two vectors.
|
inline |
Utility to check if there are any non-finite values (NaN or Inf) in this vector.
|
inlinestatic |
See if two planes are coplanar. They are coplanar if the normals are nearly parallel and the planes include the same set of points.
| Base1 | The base point in the first plane. |
| Normal1 | The normal of the first plane. |
| Base2 | The base point in the second plane. |
| Normal2 | The normal of the second plane. |
| ParallelCosineThreshold | Normals are parallel if absolute value of dot product is greater than or equal to this. |
|
inline |
Returns the cosine of the angle between this vector and another projected onto the XY plane (no Z).
| B | the other vector to find the 2D cosine of the angle with. |
|
static |
Create an orthonormal basis from a basis with at least two orthogonal vectors. It may change the directions of the X and Y axes to make the basis orthogonal, but it won'T change the direction of the Z axis. All axes will be normalized.
| XAxis | The input basis' XAxis, and upon return the orthonormal basis' XAxis. |
| YAxis | The input basis' YAxis, and upon return the orthonormal basis' YAxis. |
| ZAxis | The input basis' ZAxis, and upon return the orthonormal basis' ZAxis. |
| UE_FORCEINLINE_HINT TVector< T > UE::Math::TVector< T >::Cross | ( | const TVector< T > & | V2 | ) | const |
Calculate cross product between this and another vector.
| V | The other vector. |
|
static |
Calculate the cross product of two vectors.
| A | The first vector. |
| B | The second vector. |
|
inlinestatic |
Converts a vector containing degree values to a vector containing radian values.
| DegVector | Vector containing degree values |
|
inline |
|
inline |
|
static |
Euclidean distance between two points.
| V1 | The first point. |
| V2 | The second point. |
|
inlinestatic |
|
inlinestatic |
|
static |
Squared distance between two points.
| V1 | The first point. |
| V2 | The second point. |
|
inlinestatic |
|
static |
Squared distance between two points in the XY plane only.
| V1 | The first point. |
| V2 | The second point. |
|
static |
Euclidean distance between two points in the XY plane (ignoring Z).
| V1 | The first point. |
| V2 | The second point. |
| UE_FORCEINLINE_HINT T UE::Math::TVector< T >::Dot | ( | const TVector< T > & | V | ) | const |
Calculate the dot product between this and another vector.
| V | The other vector. |
|
static |
Calculate the dot product of two vectors.
| A | The first vector. |
| B | The second vector. |
| UE_FORCEINLINE_HINT bool UE::Math::TVector< T >::Equals | ( | const TVector< T > & | V, |
| T | Tolerance = UE_KINDA_SMALL_NUMBER |
||
| ) | const |
Check against another vector for equality, within specified error limits.
| V | The vector to check against. |
| Tolerance | Error tolerance. |
|
static |
Generates a list of sample points on a Bezier curve defined by 2 points.
| ControlPoints | Array of 4 FVectors (vert1, controlpoint1, controlpoint2, vert2). |
| NumPoints | Number of samples. |
| OutPoints | Receives the output samples. |
| void UE::Math::TVector< T >::FindBestAxisVectors | ( | TVector< T > & | Axis1, |
| TVector< T > & | Axis2 | ||
| ) | const |
Find good arbitrary axis vectors to represent U and V axes of a plane, using this vector as the normal of the plane.
| Axis1 | Reference to first axis. |
| Axis2 | Reference to second axis. |
|
static |
Given a current set of cluster centers, a set of points, iterate N times to move clusters to be central.
| Clusters | Reference to array of Clusters. |
| Points | Set of points. |
| NumIterations | Number of iterations. |
| NumConnectionsToBeValid | Sometimes you will have long strings that come off the mass of points which happen to have been chosen as Cluster starting points. You want to be able to disregard those. |
| UE_FORCEINLINE_HINT TVector< T > UE::Math::TVector< T >::GetAbs | ( | ) | const |
Get a copy of this vector with absolute value of each component.
| UE_FORCEINLINE_HINT T UE::Math::TVector< T >::GetAbsMax | ( | ) | const |
Get the maximum absolute value of the vector's components.
| UE_FORCEINLINE_HINT T UE::Math::TVector< T >::GetAbsMin | ( | ) | const |
Get the minimum 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 the maximum 2D magnitude clamped to MaxSize. Z is unchanged.
|
inline |
Create a copy of this vector, with its magnitude clamped between Min and Max.
|
inline |
Create a copy of this vector, with the 2D magnitude clamped between Min and Max. Z is unchanged.
|
inline |
Get a specific component of the vector, given a specific axis by enum
| UE_FORCEINLINE_HINT T UE::Math::TVector< T >::GetMax | ( | ) | const |
Get the maximum value of the vector's components.
| UE_FORCEINLINE_HINT T UE::Math::TVector< T >::GetMin | ( | ) | const |
Get the minimum value of the vector's components.
|
inline |
Gets a normalized copy of the vector, checking it is safe to do so based on the length. Returns zero vector by default if vector length is too small to safely normalize.
| Tolerance | Minimum squared vector length. Must be positive. |
|
inline |
Gets a normalized copy of the 2D components of the vector, checking it is safe to do so. Z is set to zero. Returns zero vector by default if vector length is too small to normalize.
| Tolerance | Minimum squared vector length. Must be positive. |
|
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 |
Calculates normalized version of vector without checking for zero length.
|
inline |
Calculates normalized 2D version of vector without checking for zero length.
| UE_FORCEINLINE_HINT TVector< T > UE::Math::TVector< T >::GridSnap | ( | const T & | GridSz | ) | const |
Gets a copy of this vector snapped to a grid.
| GridSz | Grid dimension. |
|
inline |
Convert a direction vector into a 'heading' angle.
|
inline |
Initialize this Vector based on an FString. The String is expected to contain V(0) or at least one value X=, Y=, Z=, previously produced by ToCompactString() The TVector<T> will be bogus when InitFromString returns false.
| InSourceString | FString containing the vector values. |
|
inline |
Initialize this Vector based on an FString. The String is expected to contain X=, Y=, Z=. The TVector<T> will be bogus when InitFromString returns false.
| InSourceString | FString containing the vector values. |
|
inline |
Checks whether vector is near to zero within a specified tolerance.
| Tolerance | Error tolerance. |
| UE_FORCEINLINE_HINT bool UE::Math::TVector< T >::IsNormalized | ( | ) | const |
Checks whether vector is normalized.
| UE_FORCEINLINE_HINT bool UE::Math::TVector< T >::IsUniform | ( | T | Tolerance = UE_KINDA_SMALL_NUMBER | ) | const |
Check whether X, Y and Z are nearly equal.
| Tolerance | Specified Tolerance. |
| UE_FORCEINLINE_HINT bool UE::Math::TVector< T >::IsUnit | ( | T | LengthSquaredTolerance = UE_KINDA_SMALL_NUMBER | ) | const |
Check if the vector is of unit length, with specified tolerance.
| LengthSquaredTolerance | Tolerance against squared length. |
| bool UE::Math::TVector< 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::TVector< T >::IsZero | ( | ) | const |
Checks whether all components of the vector are exactly zero.
| UE_FORCEINLINE_HINT T UE::Math::TVector< T >::Length | ( | ) | const |
Get the length (magnitude) of this vector.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Min, Max, Min3, Max3 like FMath
|
inlinestatic |
|
inline |
Mirrors a vector about a plane.
| Plane | Plane to mirror about. |
| UE_FORCEINLINE_HINT TVector< T > UE::Math::TVector< T >::MirrorByVector | ( | const TVector< T > & | MirrorNormal | ) | const |
Mirror a vector about a normal vector.
| MirrorNormal | Normal vector to mirror about. |
|
inline |
Network serialization function. FVectors NetSerialize without quantization (ie exact values are serialized). se the FVectors_NetQuantize etc (NetSerialization.h) instead.
|
inline |
Normalize this vector in-place if it is larger than a given tolerance. Leaves it unchanged if not.
| Tolerance | Minimum squared length of vector for normalization. |
|
inlinestatic |
| UE_FORCEINLINE_HINT bool UE::Math::TVector< T >::operator!= | ( | const TVector< T > & | V | ) | const |
Check against another vector for inequality.
| V | The vector to check against. |
| UE_FORCEINLINE_HINT TVector< T > UE::Math::TVector< T >::operator* | ( | const TVector< T > & | V | ) | const |
Gets the result of component-wise multiplication of this vector by another.
| V | The vector to multiply with. |
|
inline |
Gets the result of scaling the vector (multiplying each component by a value).
| Scale | What to multiply each component by. |
|
inline |
Multiplies the vector with another vector, using component-wise multiplication.
| V | What to multiply this vector with. |
|
inline |
Scales the vector.
| Scale | Amount to scale this vector by. |
| UE_FORCEINLINE_HINT TVector< T > UE::Math::TVector< T >::operator+ | ( | const TVector< T > & | V | ) | const |
Gets the result of component-wise addition of this and another vector.
| V | The vector to add to this. |
|
inline |
Gets the result of adding to each component of the vector.
| Bias | How much to add to each component. |
|
inline |
Adds another vector to this. Uses component-wise addition.
| V | Vector to add to this. |
| UE_FORCEINLINE_HINT TVector< T > UE::Math::TVector< T >::operator- | ( | ) | const |
Get a negated copy of the vector.
| UE_FORCEINLINE_HINT TVector< T > UE::Math::TVector< T >::operator- | ( | const TVector< T > & | V | ) | const |
Gets the result of component-wise subtraction of this by another vector.
| V | The vector to subtract from this. |
|
inline |
Gets the result of subtracting from each component of the vector.
| Bias | How much to subtract from each component. |
|
inline |
Subtracts another vector from this. Uses component-wise subtraction.
| V | Vector to subtract from this. |
| UE_FORCEINLINE_HINT TVector< T > UE::Math::TVector< T >::operator/ | ( | const TVector< T > & | V | ) | const |
Gets the result of component-wise division of this vector by another.
| V | The vector to divide by. |
|
inline |
Gets the result of dividing each component of the vector by a value.
| Scale | What to divide each component by. |
|
inline |
Divides the vector by another vector, using component-wise division.
| V | What to divide vector by. |
|
inline |
Divides the vector by a number.
| V | What to divide this vector by. |
| UE_FORCEINLINE_HINT bool UE::Math::TVector< T >::operator== | ( | const TVector< T > & | V | ) | const |
Check against another vector for equality.
| V | The vector to check against. |
| UE_FORCEINLINE_HINT T & UE::Math::TVector< T >::operator[] | ( | int32 | Index | ) |
Gets specific component of the vector.
| Index | the index of vector component |
| UE_FORCEINLINE_HINT T UE::Math::TVector< T >::operator[] | ( | int32 | Index | ) | const |
Gets specific component of the vector.
| Index | the index of vector component |
|
inline |
Calculate cross product between this and another vector.
| V | The other vector. |
| UE_FORCEINLINE_HINT T UE::Math::TVector< T >::operator| | ( | const TVector< T > & | V | ) | const |
Calculate the dot product between this and another vector.
| V | The other vector. |
|
inlinestatic |
See if two normal vectors are nearly orthogonal (perpendicular), meaning the angle between them is close to 90 degrees.
| Normal1 | First normalized vector. |
| Normal2 | Second normalized vector. |
| OrthogonalCosineThreshold | Normals are orthogonal if absolute value of dot product (cosine of angle between them) is less than or equal to this. For example: cos(89.0 degrees). |
|
inlinestatic |
See if two normal vectors are nearly parallel, meaning the angle between them is close to 0 degrees.
| Normal1 | First normalized vector. |
| Normal1 | Second normalized vector. |
| ParallelCosineThreshold | Normals are parallel if absolute value of dot product (cosine of angle between them) is greater than or equal to this. For example: cos(1.0 degrees). |
|
inlinestatic |
Calculate the signed distance (in the direction of the normal) between a point and a plane.
| Point | The Point we are checking. |
| PlaneBase | The Base Point in the plane. |
| PlaneNormal | The Normal of the plane (assumed to be unit length). |
|
inlinestatic |
Calculate the projection of a point on the given plane.
| Point | The point to project onto the plane |
| Plane | The plane |
|
inlinestatic |
Calculate the projection of a point on the plane defined by counter-clockwise (CCW) points A,B,C.
| Point | The point to project onto the plane |
| A | 1st of three points in CCW order defining the plane |
| B | 2nd of three points in CCW order defining the plane |
| C | 3rd of three points in CCW order defining the plane |
|
inlinestatic |
Calculate the projection of a point on the plane defined by PlaneBase and PlaneNormal.
| Point | The point to project onto the plane |
| PlaneBase | Point on the plane |
| PlaneNorm | Normal of the plane (assumed to be unit length). |
|
inlinestatic |
Compare two points and see if they're within specified distance.
| Point1 | First vector. |
| Point2 | Second vector. |
| Dist | Specified distance. |
|
inlinestatic |
Compare two points and see if they're the same, using a threshold.
| P | First vector. |
| Q | Second vector. |
|
inline |
Projects 2D components of vector based on Z.
| UE_FORCEINLINE_HINT TVector< T > UE::Math::TVector< T >::ProjectOnTo | ( | const TVector< T > & | A | ) | const |
Gets a copy of this vector projected onto the input vector.
| A | Vector to project onto, does not assume it is normalized. |
| UE_FORCEINLINE_HINT TVector< T > UE::Math::TVector< T >::ProjectOnToNormal | ( | const TVector< T > & | Normal | ) | const |
Gets a copy of this vector projected onto the input vector, which is assumed to be unit length.
| Normal | Vector to project onto (assumed to be unit length). |
|
inlinestatic |
Converts a vector containing radian values to a vector containing degree values.
| RadVector | Vector containing radian values |
|
inline |
Gets the reciprocal of this vector, avoiding division by zero. Zero components are set to BIG_NUMBER.
|
inline |
Rotates around Axis (assumes Axis.Size() == 1).
| AngleDeg | Angle to rotate (in degrees). |
| Axis | Axis to rotate around. |
|
inline |
Rotates around Axis (assumes Axis.Size() == 1).
| AngleRad | Angle to rotate (in radians). |
| Axis | Axis to rotate around. |
|
inline |
Return the UE::Math::TRotator<T> orientation corresponding to the direction in which the vector points. Sets Yaw and Pitch to the proper numbers, and sets Roll to zero because the roll can't be determined from a vector.
|
inline |
|
inline |
|
inline |
|
inline |
Set the values of the vector directly.
| InX | New X coordinate. |
| InY | New Y coordinate. |
| InZ | New Z coordinate. |
|
inline |
Set a specified componet of the vector, given a specific axis by enum
| UE_FORCEINLINE_HINT T UE::Math::TVector< T >::Size | ( | ) | const |
Get the length (magnitude) of this vector.
| UE_FORCEINLINE_HINT T UE::Math::TVector< T >::Size2D | ( | ) | const |
Get the length of the 2D components of this vector.
| UE_FORCEINLINE_HINT T UE::Math::TVector< T >::SizeSquared | ( | ) | const |
Get the squared length of this vector.
| UE_FORCEINLINE_HINT T UE::Math::TVector< T >::SizeSquared2D | ( | ) | const |
Get the squared length of the 2D components of this vector.
|
static |
Interpolate from normalized vector A to normalized vector B along a spherical path.
| NormalA | Start direction of interpolation, must be normalized. |
| NormalB | End target direction of interpolation, must be normalized. |
| Alpha | interpolation amount, usually between 0-1 |
|
static |
Interpolate from a vector to the direction of another vector along a spherical path.
| V | Vector we interpolate from |
| Direction | Target direction we interpolate to |
| Alpha | interpolation amount, usually between 0-1 |
| UE_FORCEINLINE_HINT T UE::Math::TVector< T >::SquaredLength | ( | ) | const |
Get the squared length of this vector.
|
inline |
Get a short textural representation of this vector, for compact readable logging.
|
inline |
Get a short locale aware textural representation of this vector, for compact readable logging.
|
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. |
|
inline |
| UE::Math::TQuat< T > UE::Math::TVector< T >::ToOrientationQuat | ( | ) | const |
Return the Quaternion orientation corresponding to the direction in which the vector points. Similar to the UE::Math::TRotator<T> version, returns a result without roll such that it preserves the up vector.
| UE::Math::TRotator< T > UE::Math::TVector< T >::ToOrientationRotator | ( | ) | const |
Return the TRotator orientation corresponding to the direction in which the vector points. Sets Yaw and Pitch to the proper numbers, and sets Roll to zero because the roll can'T be determined from a vector.
| UE_FORCEINLINE_HINT FString UE::Math::TVector< T >::ToString | ( | ) | const |
Get a textual representation of this vector.
|
inline |
Get a locale aware textual representation of this vector.
|
inlinestatic |
Triple product of three vectors: X dot (Y cross Z).
| X | The first vector. |
| Y | The second vector. |
| Z | The third vector. |
|
inline |
Converts a Cartesian unit vector into spherical coordinates on the unit sphere.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
| void UE::Math::TVector< T >::UnwindEuler | ( | ) |
When this vector contains Euler angles (degrees), ensure that angles are between +/-180
|
inlinestatic |
Calculate the projection of a vector on the plane defined by PlaneNormal.
| V | The vector to project onto the plane. |
| PlaneNormal | Normal of the plane (assumed to be unit length). |
|
inlinestatic |
| union { ... } UE::Math::TVector< T > |
|
static |
Unreal backward vector (-1,0,0)
|
static |
Unreal down vector (0,0,-1)
|
static |
Unreal forward vector (1,0,0)
|
static |
Unreal left vector (0,-1,0)
|
staticconstexpr |
The number of components this vector type has.
|
static |
One vector (1,1,1)
|
static |
Unreal right vector (0,1,0)
|
static |
Unreal up vector (0,0,1)
| T UE::Math::TVector< T >::X |
Vector's X component.
|
static |
Unit X axis vector (1,0,0)
| T UE::Math::TVector< T >::XYZ[3] |
| T UE::Math::TVector< T >::Y |
Vector's Y component.
|
static |
Unit Y axis vector (0,1,0)
| T UE::Math::TVector< T >::Z |
Vector's Z component.
|
static |
Unit Z axis vector (0,0,1)
|
static |
A zero vector (0,0,0)