Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
FMath Struct Reference

#include <UnrealMathUtility.h>

+ Inheritance diagram for FMath:
+ Collaboration diagram for FMath:

Public Member Functions

 RESOLVE_FLOAT_AMBIGUITY_2_ARGS (FRandRange)
 
 RESOLVE_FLOAT_PREDICATE_AMBIGUITY_2_ARGS (IsNearlyEqual)
 
 RESOLVE_FLOAT_PREDICATE_AMBIGUITY_3_ARGS (IsNearlyEqual)
 
 RESOLVE_FLOAT_PREDICATE_AMBIGUITY_2_ARGS (IsNearlyZero)
 
 MIX_FLOATS_3_ARGS (Clamp)
 
 MIX_FLOATS_2_ARGS (GridSnap)
 
 RESOLVE_FLOAT_AMBIGUITY_3_ARGS (ClampAngle)
 
template<typename T >
UE::Math::TVector< TLinePlaneIntersection (const UE::Math::TVector< T > &Point1, const UE::Math::TVector< T > &Point2, const UE::Math::TVector< T > &PlaneOrigin, const UE::Math::TVector< T > &PlaneNormal)
 
template<typename T >
bool LineSphereIntersection (const UE::Math::TVector< T > &Start, const UE::Math::TVector< T > &Dir, T Length, const UE::Math::TVector< T > &Origin, T Radius)
 
template<typename T , typename U >
FORCEINLINE_DEBUGGABLE UE::Math::TRotator< TLerpRange (const UE::Math::TRotator< T > &A, const UE::Math::TRotator< T > &B, U Alpha)
 
template<typename T >
FORCEINLINE_DEBUGGABLE T ClampAngle (T AngleDegrees, T MinAngleDegrees, T MaxAngleDegrees)
 
template<typename T >
UE::Math::TVector< TRayPlaneIntersection (const UE::Math::TVector< T > &RayOrigin, const UE::Math::TVector< T > &RayDirection, const UE::Math::TPlane< T > &Plane)
 
template<typename T >
T RayPlaneIntersectionParam (const UE::Math::TVector< T > &RayOrigin, const UE::Math::TVector< T > &RayDirection, const UE::Math::TPlane< T > &Plane)
 
template<typename T >
UE::Math::TVector< TLinePlaneIntersection (const UE::Math::TVector< T > &Point1, const UE::Math::TVector< T > &Point2, const UE::Math::TPlane< T > &Plane)
 
template<typename T >
bool IntersectPlanes3 (UE::Math::TVector< T > &I, const UE::Math::TPlane< T > &P1, const UE::Math::TPlane< T > &P2, const UE::Math::TPlane< T > &P3)
 
template<typename T >
bool IntersectPlanes2 (UE::Math::TVector< T > &I, UE::Math::TVector< T > &D, const UE::Math::TPlane< T > &P1, const UE::Math::TPlane< T > &P2)
 
template<typename FReal >
bool PointBoxIntersection (const UE::Math::TVector< FReal > &Point, const UE::Math::TBox< FReal > &Box)
 
template<typename FReal >
bool LineBoxIntersection (const UE::Math::TBox< FReal > &Box, const UE::Math::TVector< FReal > &Start, const UE::Math::TVector< FReal > &End, const UE::Math::TVector< FReal > &StartToEnd)
 
template<typename FReal >
bool LineBoxIntersection (const UE::Math::TBox< FReal > &Box, const UE::Math::TVector< FReal > &Start, const UE::Math::TVector< FReal > &End, const UE::Math::TVector< FReal > &StartToEnd, const UE::Math::TVector< FReal > &OneOverStartToEnd)
 
template<typename FReal >
bool SphereAABBIntersection (const UE::Math::TVector< FReal > &SphereCenter, const FReal RadiusSquared, const UE::Math::TBox< FReal > &AABB)
 
template<typename FReal >
bool SphereAABBIntersection (const UE::Math::TSphere< FReal > &Sphere, const UE::Math::TBox< FReal > &AABB)
 
template<typename FReal >
FORCEINLINE UE::Math::TSphere< FReal > ComputeBoundingSphereForCone (UE::Math::TVector< FReal > const &ConeOrigin, UE::Math::TVector< FReal > const &ConeDirection, FReal ConeRadius, FReal CosConeAngle, FReal SinConeAngle)
 

Static Public Member Functions

static UE_NODISCARD FORCEINLINE int32 RandHelper (int32 A)
 
static UE_NODISCARD FORCEINLINE int64 RandHelper64 (int64 A)
 
static UE_NODISCARD FORCEINLINE int32 RandRange (int32 Min, int32 Max)
 
static UE_NODISCARD FORCEINLINE int64 RandRange (int64 Min, int64 Max)
 
static UE_NODISCARD FORCEINLINE float RandRange (float InMin, float InMax)
 
static UE_NODISCARD FORCEINLINE double RandRange (double InMin, double InMax)
 
static UE_NODISCARD FORCEINLINE float FRandRange (float InMin, float InMax)
 
static UE_NODISCARD FORCEINLINE double FRandRange (double InMin, double InMax)
 
static UE_NODISCARD FORCEINLINE bool RandBool ()
 
static UE_NODISCARD FVector VRand ()
 
static UE_NODISCARD FVector VRandCone (FVector const &Dir, float ConeHalfAngleRad)
 
static UE_NODISCARD FVector VRandCone (FVector const &Dir, float HorizontalConeHalfAngleRad, float VerticalConeHalfAngleRad)
 
static UE_NODISCARD FVector2D RandPointInCircle (float CircleRadius)
 
static UE_NODISCARD FVector RandPointInBox (const FBox &Box)
 
static UE_NODISCARD FVector GetReflectionVector (const FVector &Direction, const FVector &SurfaceNormal)
 
template<class T , class U >
static UE_NODISCARD constexpr FORCEINLINE bool IsWithin (const T &TestValue, const U &MinValue, const U &MaxValue)
 
template<class T , class U >
static UE_NODISCARD constexpr FORCEINLINE bool IsWithinInclusive (const T &TestValue, const U &MinValue, const U &MaxValue)
 
static UE_NODISCARD FORCEINLINE bool IsNearlyEqual (float A, float B, float ErrorTolerance=UE_SMALL_NUMBER)
 
static UE_NODISCARD FORCEINLINE bool IsNearlyEqual (double A, double B, double ErrorTolerance=UE_DOUBLE_SMALL_NUMBER)
 
static UE_NODISCARD FORCEINLINE bool IsNearlyZero (float Value, float ErrorTolerance=UE_SMALL_NUMBER)
 
static UE_NODISCARD FORCEINLINE bool IsNearlyZero (double Value, double ErrorTolerance=UE_DOUBLE_SMALL_NUMBER)
 
static UE_NODISCARD FORCEINLINE bool IsNearlyEqualByULP (float A, float B, int32 MaxUlps=4)
 
static UE_NODISCARD FORCEINLINE bool IsNearlyEqualByULP (double A, double B, int32 MaxUlps=4)
 
template<typename T >
static UE_NODISCARD constexpr FORCEINLINE bool IsPowerOfTwo (T Value)
 
static UE_NODISCARD FORCEINLINE float Floor (float F)
 
static UE_NODISCARD FORCEINLINE double Floor (double F)
 
template<typename IntegralType UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr FORCEINLINE IntegralType Floor (IntegralType I)
 
template<class T >
static UE_NODISCARD constexpr FORCEINLINE T Max3 (const T A, const T B, const T C)
 
template<class T >
static UE_NODISCARD constexpr FORCEINLINE T Min3 (const T A, const T B, const T C)
 
template<class T >
static UE_NODISCARD constexpr FORCEINLINE int32 Max3Index (const T A, const T B, const T C)
 
template<class T >
static UE_NODISCARD constexpr FORCEINLINE int32 Min3Index (const T A, const T B, const T C)
 
template<class T >
static UE_NODISCARD constexpr FORCEINLINE T Square (const T A)
 
template<class T >
static UE_NODISCARD constexpr FORCEINLINE T Cube (const T A)
 
template<class T >
static UE_NODISCARD constexpr FORCEINLINE T Clamp (const T X, const T Min, const T Max)
 
static UE_NODISCARD constexpr FORCEINLINE float Clamp (const float X, const float Min, const float Max)
 
static UE_NODISCARD constexpr FORCEINLINE double Clamp (const double X, const double Min, const double Max)
 
static UE_NODISCARD constexpr FORCEINLINE int64 Clamp (const int64 X, const int32 Min, const int32 Max)
 
template<class T >
static UE_NODISCARD constexpr FORCEINLINE T Wrap (const T X, const T Min, const T Max)
 
template<class T >
static UE_NODISCARD constexpr FORCEINLINE T GridSnap (T Location, T Grid)
 
template<class T >
static UE_NODISCARD constexpr FORCEINLINE T DivideAndRoundUp (T Dividend, T Divisor)
 
template<class T >
static UE_NODISCARD constexpr FORCEINLINE T DivideAndRoundDown (T Dividend, T Divisor)
 
template<class T >
static UE_NODISCARD constexpr FORCEINLINE T DivideAndRoundNearest (T Dividend, T Divisor)
 
static UE_NODISCARD FORCEINLINE float Log2 (float Value)
 
static UE_NODISCARD FORCEINLINE double Log2 (double Value)
 
template<typename T UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static constexpr FORCEINLINE void SinCos (std::decay_t< T > *ScalarSin, std::decay_t< T > *ScalarCos, T Value)
 
static FORCEINLINE void SinCos (double *ScalarSin, double *ScalarCos, double Value)
 
template<typename T , typename U UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static FORCEINLINE void SinCos (T *ScalarSin, T *ScalarCos, U Value)
 
static UE_NODISCARD FORCEINLINE float FastAsin (float Value)
 
static UE_NODISCARD FORCEINLINE double FastAsin (double Value)
 
template<class T >
static UE_NODISCARD constexpr FORCEINLINE auto RadiansToDegrees (T const &RadVal) -> decltype(RadVal *(180.f/UE_PI))
 
static FORCEINLINE float RadiansToDegrees (float const &RadVal)
 
static FORCEINLINE double RadiansToDegrees (double const &RadVal)
 
template<class T >
static UE_NODISCARD constexpr FORCEINLINE auto DegreesToRadians (T const &DegVal) -> decltype(DegVal *(UE_PI/180.f))
 
static FORCEINLINE float DegreesToRadians (float const &DegVal)
 
static FORCEINLINE double DegreesToRadians (double const &DegVal)
 
template<typename T >
static UE_NODISCARD T ClampAngle (T AngleDegrees, T MinAngleDegrees, T MaxAngleDegrees)
 
template<typename T , typename T2 UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr auto FindDeltaAngleDegrees (T A1, T2 A2) -> decltype(A1 *A2)
 
template<typename T , typename T2 UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr auto FindDeltaAngleRadians (T A1, T2 A2) -> decltype(A1 *A2)
 
template<typename T UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr T UnwindRadians (T A)
 
template<typename T UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr T UnwindDegrees (T A)
 
static void WindRelativeAnglesDegrees (float InAngle0, float &InOutAngle1)
 
static void WindRelativeAnglesDegrees (double InAngle0, double &InOutAngle1)
 
static UE_NODISCARD float FixedTurn (float InCurrent, float InDesired, float InDeltaRate)
 
template<typename T >
static FORCEINLINE void CartesianToPolar (const T X, const T Y, T &OutRad, T &OutAng)
 
template<typename T >
static FORCEINLINE void CartesianToPolar (const UE::Math::TVector2< T > InCart, UE::Math::TVector2< T > &OutPolar)
 
template<typename T >
static FORCEINLINE void PolarToCartesian (const T Rad, const T Ang, T &OutX, T &OutY)
 
template<typename T >
static FORCEINLINE void PolarToCartesian (const UE::Math::TVector2< T > InPolar, UE::Math::TVector2< T > &OutCart)
 
static bool GetDotDistance (FVector2D &OutDotDist, const FVector &Direction, const FVector &AxisX, const FVector &AxisY, const FVector &AxisZ)
 
static UE_NODISCARD FVector2D GetAzimuthAndElevation (const FVector &Direction, const FVector &AxisX, const FVector &AxisY, const FVector &AxisZ)
 
template<typename T , typename T2 UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr FORCEINLINE auto GetRangePct (T MinValue, T MaxValue, T2 Value)
 
template<typename T , typename T2 UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD auto GetRangePct (UE::Math::TVector2< T > const &Range, T2 Value)
 
template<typename T , typename T2 UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD auto GetRangeValue (UE::Math::TVector2< T > const &Range, T2 Pct)
 
template<typename T , typename T2 >
static UE_NODISCARD FORCEINLINE auto GetMappedRangeValueClamped (const UE::Math::TVector2< T > &InputRange, const UE::Math::TVector2< T > &OutputRange, const T2 Value)
 
template<typename T , typename T2 >
static UE_NODISCARD FORCEINLINE auto GetMappedRangeValueUnclamped (const UE::Math::TVector2< T > &InputRange, const UE::Math::TVector2< T > &OutputRange, const T2 Value)
 
template<class T >
static UE_NODISCARD FORCEINLINE double GetRangePct (TRange< T > const &Range, T Value)
 
template<class T >
static UE_NODISCARD FORCEINLINE T GetRangeValue (TRange< T > const &Range, T Pct)
 
template<class T >
static UE_NODISCARD FORCEINLINE T GetMappedRangeValueClamped (const TRange< T > &InputRange, const TRange< T > &OutputRange, const T Value)
 
template<typename T , typename U UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE T Lerp (const T &A, const T &B, const U &Alpha)
 
template<typename T , typename U UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T Lerp (const T &A, const T &B, const U &Alpha)
 
template<typename T1 , typename T2 , typename T3 UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD auto Lerp (const T1 &A, const T2 &B, const T3 &Alpha) -> decltype(A *B)
 
template<class T >
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE T LerpStable (const T &A, const T &B, double Alpha)
 
template<class T >
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE T LerpStable (const T &A, const T &B, float Alpha)
 
template<typename T1 , typename T2 , typename T3 UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD auto LerpStable (const T1 &A, const T2 &B, const T3 &Alpha) -> decltype(A *B)
 
template<typename T , typename U UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE T BiLerp (const T &P00, const T &P10, const T &P01, const T &P11, const U &FracX, const U &FracY)
 
template<typename T , typename U UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T BiLerp (const T &P00, const T &P10, const T &P01, const T &P11, const U &FracX, const U &FracY)
 
template<typename T , typename U UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE T CubicInterp (const T &P0, const T &T0, const T &P1, const T &T1, const U &A)
 
template<typename T , typename U UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T CubicInterp (const T &P0, const T &T0, const T &P1, const T &T1, const U &A)
 
template<typename T , typename U UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE T CubicInterpDerivative (const T &P0, const T &T0, const T &P1, const T &T1, const U &A)
 
template<typename T , typename U UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE T CubicInterpSecondDerivative (const T &P0, const T &T0, const T &P1, const T &T1, const U &A)
 
template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T InterpEaseIn (const T &A, const T &B, float Alpha, float Exp)
 
template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T InterpEaseOut (const T &A, const T &B, float Alpha, float Exp)
 
template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T InterpEaseInOut (const T &A, const T &B, float Alpha, float Exp)
 
template<class T >
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE T InterpStep (const T &A, const T &B, float Alpha, int32 Steps)
 
template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T InterpSinIn (const T &A, const T &B, float Alpha)
 
template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T InterpSinOut (const T &A, const T &B, float Alpha)
 
template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T InterpSinInOut (const T &A, const T &B, float Alpha)
 
template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T InterpExpoIn (const T &A, const T &B, float Alpha)
 
template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T InterpExpoOut (const T &A, const T &B, float Alpha)
 
template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T InterpExpoInOut (const T &A, const T &B, float Alpha)
 
template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T InterpCircularIn (const T &A, const T &B, float Alpha)
 
template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T InterpCircularOut (const T &A, const T &B, float Alpha)
 
template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T InterpCircularInOut (const T &A, const T &B, float Alpha)
 
template<typename T , typename U >
static UE_NODISCARD UE::Math::TRotator< TLerpRange (const UE::Math::TRotator< T > &A, const UE::Math::TRotator< T > &B, U Alpha)
 
template<class U >
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE U CubicCRSplineInterp (const U &P0, const U &P1, const U &P2, const U &P3, const float T0, const float T1, const float T2, const float T3, const float T)
 
template<class U >
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE U CubicCRSplineInterpSafe (const U &P0, const U &P1, const U &P2, const U &P3, const float T0, const float T1, const float T2, const float T3, const float T)
 
static UE_NODISCARD FVector VInterpNormalRotationTo (const FVector &Current, const FVector &Target, float DeltaTime, float RotationSpeedDegrees)
 
static UE_NODISCARD FVector VInterpConstantTo (const FVector &Current, const FVector &Target, float DeltaTime, float InterpSpeed)
 
static UE_NODISCARD FVector VInterpTo (const FVector &Current, const FVector &Target, float DeltaTime, float InterpSpeed)
 
static UE_NODISCARD FVector2D Vector2DInterpConstantTo (const FVector2D &Current, const FVector2D &Target, float DeltaTime, float InterpSpeed)
 
static UE_NODISCARD FVector2D Vector2DInterpTo (const FVector2D &Current, const FVector2D &Target, float DeltaTime, float InterpSpeed)
 
static UE_NODISCARD FRotator RInterpConstantTo (const FRotator &Current, const FRotator &Target, float DeltaTime, float InterpSpeed)
 
static UE_NODISCARD FRotator RInterpTo (const FRotator &Current, const FRotator &Target, float DeltaTime, float InterpSpeed)
 
template<typename T1 , typename T2 = T1, typename T3 = T2, typename T4 = T3>
static UE_NODISCARD auto FInterpConstantTo (T1 Current, T2 Target, T3 DeltaTime, T4 InterpSpeed)
 
template<typename T1 , typename T2 = T1, typename T3 = T2, typename T4 = T3>
static UE_NODISCARD auto FInterpTo (T1 Current, T2 Target, T3 DeltaTime, T4 InterpSpeed)
 
static UE_NODISCARD FLinearColor CInterpTo (const FLinearColor &Current, const FLinearColor &Target, float DeltaTime, float InterpSpeed)
 
template<class T >
static UE_NODISCARD UE::Math::TQuat< TQInterpConstantTo (const UE::Math::TQuat< T > &Current, const UE::Math::TQuat< T > &Target, float DeltaTime, float InterpSpeed)
 
template<class T >
static UE_NODISCARD UE::Math::TQuat< TQInterpTo (const UE::Math::TQuat< T > &Current, const UE::Math::TQuat< T > &Target, float DeltaTime, float InterpSpeed)
 
template<class T >
static UE_NODISCARD constexpr T InvExpApprox (T X)
 
template<class T >
static constexpr void ExponentialSmoothingApprox (T &InOutValue, const T &InTargetValue, const float InDeltaTime, const float InSmoothingTime)
 
template<class T >
static constexpr void CriticallyDampedSmoothing (T &InOutValue, T &InOutValueRate, const T &InTargetValue, const T &InTargetValueRate, const float InDeltaTime, const float InSmoothingTime)
 
template<class T >
static void SpringDamper (T &InOutValue, T &InOutValueRate, const T &InTargetValue, const T &InTargetValueRate, const float InDeltaTime, const float InUndampedFrequency, const float InDampingRatio)
 
template<class T >
static void SpringDamperSmoothing (T &InOutValue, T &InOutValueRate, const T &InTargetValue, const T &InTargetValueRate, const float InDeltaTime, const float InSmoothingTime, const float InDampingRatio)
 
static UE_NODISCARD float MakePulsatingValue (const double InCurrentTime, const float InPulsesPerSecond, const float InPhase=0.0f)
 
template<typename FReal >
static UE_NODISCARD UE::Math::TVector< FReal > RayPlaneIntersection (const UE::Math::TVector< FReal > &RayOrigin, const UE::Math::TVector< FReal > &RayDirection, const UE::Math::TPlane< FReal > &Plane)
 
template<typename FReal >
static UE_NODISCARD FReal RayPlaneIntersectionParam (const UE::Math::TVector< FReal > &RayOrigin, const UE::Math::TVector< FReal > &RayDirection, const UE::Math::TPlane< FReal > &Plane)
 
template<typename FReal >
static UE_NODISCARD UE::Math::TVector< FReal > LinePlaneIntersection (const UE::Math::TVector< FReal > &Point1, const UE::Math::TVector< FReal > &Point2, const UE::Math::TVector< FReal > &PlaneOrigin, const UE::Math::TVector< FReal > &PlaneNormal)
 
template<typename FReal >
static UE_NODISCARD UE::Math::TVector< FReal > LinePlaneIntersection (const UE::Math::TVector< FReal > &Point1, const UE::Math::TVector< FReal > &Point2, const UE::Math::TPlane< FReal > &Plane)
 
static UE_NODISCARD uint32 ComputeProjectedSphereScissorRect (FIntRect &InOutScissorRect, FVector SphereOrigin, float Radius, FVector ViewOrigin, const FMatrix &ViewMatrix, const FMatrix &ProjMatrix)
 
template<typename FReal >
static UE_NODISCARD UE::Math::TSphere< FReal > ComputeBoundingSphereForCone (UE::Math::TVector< FReal > const &ConeOrigin, UE::Math::TVector< FReal > const &ConeDirection, FReal ConeRadius, FReal CosConeAngle, FReal SinConeAngle)
 
static UE_NODISCARD bool PlaneAABBIntersection (const FPlane &P, const FBox &AABB)
 
static UE_NODISCARD int32 PlaneAABBRelativePosition (const FPlane &P, const FBox &AABB)
 
template<typename FReal >
static UE_NODISCARD bool SphereAABBIntersection (const UE::Math::TVector< FReal > &SphereCenter, const FReal RadiusSquared, const UE::Math::TBox< FReal > &AABB)
 
template<typename FReal >
static UE_NODISCARD bool SphereAABBIntersection (const UE::Math::TSphere< FReal > &Sphere, const UE::Math::TBox< FReal > &AABB)
 
template<typename FReal >
static UE_NODISCARD bool PointBoxIntersection (const UE::Math::TVector< FReal > &Point, const UE::Math::TBox< FReal > &Box)
 
template<typename FReal >
static UE_NODISCARD bool LineBoxIntersection (const UE::Math::TBox< FReal > &Box, const UE::Math::TVector< FReal > &Start, const UE::Math::TVector< FReal > &End, const UE::Math::TVector< FReal > &Direction)
 
template<typename FReal >
static UE_NODISCARD bool LineBoxIntersection (const UE::Math::TBox< FReal > &Box, const UE::Math::TVector< FReal > &Start, const UE::Math::TVector< FReal > &End, const UE::Math::TVector< FReal > &Direction, const UE::Math::TVector< FReal > &OneOverDirection)
 
static bool LineExtentBoxIntersection (const FBox &inBox, const FVector &Start, const FVector &End, const FVector &Extent, FVector &HitLocation, FVector &HitNormal, float &HitTime)
 
template<typename FReal >
static UE_NODISCARD bool LineSphereIntersection (const UE::Math::TVector< FReal > &Start, const UE::Math::TVector< FReal > &Dir, FReal Length, const UE::Math::TVector< FReal > &Origin, FReal Radius)
 
static UE_NODISCARD bool SphereConeIntersection (const FVector &SphereCenter, float SphereRadius, const FVector &ConeAxis, float ConeAngleSin, float ConeAngleCos)
 
static UE_NODISCARD FVector ClosestPointOnLine (const FVector &LineStart, const FVector &LineEnd, const FVector &Point)
 
static UE_NODISCARD FVector ClosestPointOnInfiniteLine (const FVector &LineStart, const FVector &LineEnd, const FVector &Point)
 
template<typename FReal >
static UE_NODISCARD bool IntersectPlanes3 (UE::Math::TVector< FReal > &I, const UE::Math::TPlane< FReal > &P1, const UE::Math::TPlane< FReal > &P2, const UE::Math::TPlane< FReal > &P3)
 
template<typename FReal >
static UE_NODISCARD bool IntersectPlanes2 (UE::Math::TVector< FReal > &I, UE::Math::TVector< FReal > &D, const UE::Math::TPlane< FReal > &P1, const UE::Math::TPlane< FReal > &P2)
 
static float PointDistToLine (const FVector &Point, const FVector &Direction, const FVector &Origin, FVector &OutClosestPoint)
 
static UE_NODISCARD float PointDistToLine (const FVector &Point, const FVector &Direction, const FVector &Origin)
 
static UE_NODISCARD FVector ClosestPointOnSegment (const FVector &Point, const FVector &StartPoint, const FVector &EndPoint)
 
static UE_NODISCARD FVector2D ClosestPointOnSegment2D (const FVector2D &Point, const FVector2D &StartPoint, const FVector2D &EndPoint)
 
static UE_NODISCARD float PointDistToSegment (const FVector &Point, const FVector &StartPoint, const FVector &EndPoint)
 
static UE_NODISCARD float PointDistToSegmentSquared (const FVector &Point, const FVector &StartPoint, const FVector &EndPoint)
 
static void SegmentDistToSegment (FVector A1, FVector B1, FVector A2, FVector B2, FVector &OutP1, FVector &OutP2)
 
static void SegmentDistToSegmentSafe (FVector A1, FVector B1, FVector A2, FVector B2, FVector &OutP1, FVector &OutP2)
 
static UE_NODISCARD float GetTForSegmentPlaneIntersect (const FVector &StartPoint, const FVector &EndPoint, const FPlane &Plane)
 
static bool SegmentPlaneIntersection (const FVector &StartPoint, const FVector &EndPoint, const FPlane &Plane, FVector &out_IntersectionPoint)
 
static bool SegmentTriangleIntersection (const FVector &StartPoint, const FVector &EndPoint, const FVector &A, const FVector &B, const FVector &C, FVector &OutIntersectPoint, FVector &OutTriangleNormal)
 
static bool SegmentIntersection2D (const FVector &SegmentStartA, const FVector &SegmentEndA, const FVector &SegmentStartB, const FVector &SegmentEndB, FVector &out_IntersectionPoint)
 
static UE_NODISCARD FVector ClosestPointOnTriangleToPoint (const FVector &Point, const FVector &A, const FVector &B, const FVector &C)
 
static UE_NODISCARD FVector ClosestPointOnTetrahedronToPoint (const FVector &Point, const FVector &A, const FVector &B, const FVector &C, const FVector &D)
 
static void SphereDistToLine (FVector SphereOrigin, float SphereRadius, FVector LineOrigin, FVector LineDir, FVector &OutClosestPoint)
 
static UE_NODISCARD bool GetDistanceWithinConeSegment (FVector Point, FVector ConeStartPoint, FVector ConeLine, float RadiusAtStart, float RadiusAtEnd, float &PercentageOut)
 
static UE_NODISCARD bool PointsAreCoplanar (const TArray< FVector > &Points, const float Tolerance=0.1f)
 
static UE_NODISCARD float TruncateToHalfIfClose (float F, float Tolerance=UE_SMALL_NUMBER)
 
static UE_NODISCARD double TruncateToHalfIfClose (double F, double Tolerance=UE_SMALL_NUMBER)
 
static UE_NODISCARD float RoundHalfToEven (float F)
 
static UE_NODISCARD double RoundHalfToEven (double F)
 
static UE_NODISCARD float RoundHalfFromZero (float F)
 
static UE_NODISCARD double RoundHalfFromZero (double F)
 
static UE_NODISCARD float RoundHalfToZero (float F)
 
static UE_NODISCARD double RoundHalfToZero (double F)
 
static UE_NODISCARD FORCEINLINE float RoundFromZero (float F)
 
static UE_NODISCARD FORCEINLINE double RoundFromZero (double F)
 
static UE_NODISCARD FORCEINLINE float RoundToZero (float F)
 
static UE_NODISCARD FORCEINLINE double RoundToZero (double F)
 
static UE_NODISCARD FORCEINLINE float RoundToNegativeInfinity (float F)
 
static UE_NODISCARD FORCEINLINE double RoundToNegativeInfinity (double F)
 
static UE_NODISCARD FORCEINLINE float RoundToPositiveInfinity (float F)
 
static UE_NODISCARD FORCEINLINE double RoundToPositiveInfinity (double F)
 
static UE_NODISCARD FString FormatIntToHumanReadable (int32 Val)
 
static UE_NODISCARD bool MemoryTest (void *BaseAddress, uint32 NumBytes)
 
static bool Eval (FString Str, float &OutValue)
 
static UE_NODISCARD FVector GetBaryCentric2D (const FVector &Point, const FVector &A, const FVector &B, const FVector &C)
 
static UE_NODISCARD FVector GetBaryCentric2D (const FVector2D &Point, const FVector2D &A, const FVector2D &B, const FVector2D &C)
 
static UE_NODISCARD FVector ComputeBaryCentric2D (const FVector &Point, const FVector &A, const FVector &B, const FVector &C)
 
static UE_NODISCARD FVector4 ComputeBaryCentric3D (const FVector &Point, const FVector &A, const FVector &B, const FVector &C, const FVector &D)
 
template<typename T >
static UE_NODISCARD constexpr T SmoothStep (T A, T B, T X)
 
static UE_NODISCARD constexpr bool ExtractBoolFromBitfield (uint8 *Ptr, uint32 Index)
 
static constexpr void SetBoolInBitField (uint8 *Ptr, uint32 Index, bool bSet)
 
static void ApplyScaleToFloat (float &Dst, const FVector &DeltaScale, float Magnitude=1.0f)
 
static UE_NODISCARD uint8 Quantize8UnsignedByte (float x)
 
static UE_NODISCARD uint8 Quantize8SignedByte (float x)
 
static UE_NODISCARD constexpr int32 GreatestCommonDivisor (int32 a, int32 b)
 
static UE_NODISCARD constexpr int32 LeastCommonMultiplier (int32 a, int32 b)
 
static UE_NODISCARD float PerlinNoise1D (float Value)
 
static UE_NODISCARD float PerlinNoise2D (const FVector2D &Location)
 
static UE_NODISCARD float PerlinNoise3D (const FVector &Location)
 
template<typename T >
static UE_NODISCARD T WeightedMovingAverage (T CurrentSample, T PreviousSample, T Weight)
 
template<typename T >
static UE_NODISCARD T DynamicWeightedMovingAverage (T CurrentSample, T PreviousSample, T MaxDistance, T MinWeight, T MaxWeight)
 

Static Public Attributes

static const uint32 BitFlag [32]
 

Static Private Member Functions

template<typename FloatType , typename IntegralType , IntegralType SignedBit>
static bool TIsNearlyEqualByULP (FloatType A, FloatType B, int32 MaxUlps)
 

Detailed Description

Structure for all math helper functions, inherits from platform math to pick up platform-specific implementations Check GenericPlatformMath.h for additional math functions

Definition at line 260 of file UnrealMathUtility.h.

Member Function Documentation

◆ ApplyScaleToFloat()

static void FMath::ApplyScaleToFloat ( float & Dst,
const FVector & DeltaScale,
float Magnitude = 1.0f )
static

Handy to apply scaling in the editor

Parameters
Dstin and out

◆ BiLerp() [1/2]

template<typename T , typename U UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE T FMath::BiLerp ( const T & P00,
const T & P10,
const T & P01,
const T & P11,
const U & FracX,
const U & FracY )
inlinestaticconstexpr

Performs a 2D linear interpolation between four values values, FracX, FracY ranges from 0-1

Definition at line 1193 of file UnrealMathUtility.h.

◆ BiLerp() [2/2]

template<typename T , typename U UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T FMath::BiLerp ( const T & P00,
const T & P10,
const T & P01,
const T & P11,
const U & FracX,
const U & FracY )
inlinestatic

Custom lerps defined for those classes not suited to the default implemenation.

Definition at line 1210 of file UnrealMathUtility.h.

◆ CartesianToPolar() [1/2]

template<typename T >
static FORCEINLINE void FMath::CartesianToPolar ( const T X,
const T Y,
T & OutRad,
T & OutAng )
inlinestatic

Converts given Cartesian coordinate pair to Polar coordinate system.

Definition at line 967 of file UnrealMathUtility.h.

◆ CartesianToPolar() [2/2]

template<typename T >
static FORCEINLINE void FMath::CartesianToPolar ( const UE::Math::TVector2< T > InCart,
UE::Math::TVector2< T > & OutPolar )
inlinestatic

Converts given Cartesian coordinate pair to Polar coordinate system.

Definition at line 974 of file UnrealMathUtility.h.

◆ CInterpTo()

static UE_NODISCARD FLinearColor FMath::CInterpTo ( const FLinearColor & Current,
const FLinearColor & Target,
float DeltaTime,
float InterpSpeed )
static

Interpolate Linear Color from Current to Target. Scaled by distance to Target, so it has a strong start speed and ease out.

◆ Clamp() [1/4]

static UE_NODISCARD constexpr FORCEINLINE double FMath::Clamp ( const double X,
const double Min,
const double Max )
inlinestaticconstexpr

Definition at line 597 of file UnrealMathUtility.h.

◆ Clamp() [2/4]

static UE_NODISCARD constexpr FORCEINLINE float FMath::Clamp ( const float X,
const float Min,
const float Max )
inlinestaticconstexpr

Clamps X to be between Min and Max, inclusive. Explicitly defined here for floats/doubles because static analysis gets confused between template and int versions.

Definition at line 596 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

◆ Clamp() [3/4]

static UE_NODISCARD constexpr FORCEINLINE int64 FMath::Clamp ( const int64 X,
const int32 Min,
const int32 Max )
inlinestaticconstexpr

Clamps X to be between Min and Max, inclusive. Overload to support mixed int64/int32 types.

Definition at line 600 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

◆ Clamp() [4/4]

template<class T >
static UE_NODISCARD constexpr FORCEINLINE T FMath::Clamp ( const T X,
const T Min,
const T Max )
inlinestaticconstexpr

Clamps X to be between Min and Max, inclusive

Definition at line 588 of file UnrealMathUtility.h.

◆ ClampAngle() [1/2]

template<typename T >
FORCEINLINE_DEBUGGABLE T FMath::ClampAngle ( T AngleDegrees,
T MinAngleDegrees,
T MaxAngleDegrees )

Definition at line 920 of file Rotator.h.

◆ ClampAngle() [2/2]

template<typename T >
static UE_NODISCARD T FMath::ClampAngle ( T AngleDegrees,
T MinAngleDegrees,
T MaxAngleDegrees )
static

Clamps an arbitrary angle to be between the given angles. Will clamp to nearest boundary.

Parameters
MinAngleDegrees"from" angle that defines the beginning of the range of valid angles (sweeping clockwise)
MaxAngleDegrees"to" angle that defines the end of the range of valid angles
Returns
Returns clamped angle in the range -180..180.

◆ ClosestPointOnInfiniteLine()

static UE_NODISCARD FVector FMath::ClosestPointOnInfiniteLine ( const FVector & LineStart,
const FVector & LineEnd,
const FVector & Point )
static

Find the point on the infinite line between two points (LineStart, LineEnd) which is closest to Point

◆ ClosestPointOnLine()

static UE_NODISCARD FVector FMath::ClosestPointOnLine ( const FVector & LineStart,
const FVector & LineEnd,
const FVector & Point )
static

Find the point on the line segment from LineStart to LineEnd which is closest to Point

◆ ClosestPointOnSegment()

static UE_NODISCARD FVector FMath::ClosestPointOnSegment ( const FVector & Point,
const FVector & StartPoint,
const FVector & EndPoint )
static

Returns closest point on a segment to a given point. The idea is to project point on line formed by segment. Then we see if the closest point on the line is outside of segment or inside.

Parameters
Pointpoint for which we find the closest point on the segment
StartPointStartPoint of segment
EndPointEndPoint of segment
Returns
point on the segment defined by (StartPoint, EndPoint) that is closest to Point.

◆ ClosestPointOnSegment2D()

static UE_NODISCARD FVector2D FMath::ClosestPointOnSegment2D ( const FVector2D & Point,
const FVector2D & StartPoint,
const FVector2D & EndPoint )
static

FVector2D version of ClosestPointOnSegment. Returns closest point on a segment to a given 2D point. The idea is to project point on line formed by segment. Then we see if the closest point on the line is outside of segment or inside.

Parameters
Pointpoint for which we find the closest point on the segment
StartPointStartPoint of segment
EndPointEndPoint of segment
Returns
point on the segment defined by (StartPoint, EndPoint) that is closest to Point.

◆ ClosestPointOnTetrahedronToPoint()

static UE_NODISCARD FVector FMath::ClosestPointOnTetrahedronToPoint ( const FVector & Point,
const FVector & A,
const FVector & B,
const FVector & C,
const FVector & D )
static

Returns closest point on a tetrahedron to a point. The idea is to identify the halfplanes that the point is in relative to each face of the tetrahedron

Parameters
Pointpoint to check distance for
A,B,C,Dfour points defining a tetrahedron
Returns
Point on tetrahedron ABCD closest to given point

◆ ClosestPointOnTriangleToPoint()

static UE_NODISCARD FVector FMath::ClosestPointOnTriangleToPoint ( const FVector & Point,
const FVector & A,
const FVector & B,
const FVector & C )
static

Returns closest point on a triangle to a point. The idea is to identify the halfplanes that the point is in relative to each triangle segment "plane"

Parameters
Pointpoint to check distance for
A,B,Ccounter clockwise ordering of points defining a triangle
Returns
Point on triangle ABC closest to given point

◆ ComputeBaryCentric2D()

static UE_NODISCARD FVector FMath::ComputeBaryCentric2D ( const FVector & Point,
const FVector & A,
const FVector & B,
const FVector & C )
static

Computes the barycentric coordinates for a given point in a triangle

Parameters
Pointpoint to convert to barycentric coordinates (in plane of ABC)
A,B,Cthree non-collinear points defining a triangle in CCW
Returns
Vector containing the three weights a,b,c such that Point = a*A + b*B + c*C or Point = A + b*(B-A) + c*(C-A) = (1-b-c)*A + b*B + c*C

◆ ComputeBaryCentric3D()

static UE_NODISCARD FVector4 FMath::ComputeBaryCentric3D ( const FVector & Point,
const FVector & A,
const FVector & B,
const FVector & C,
const FVector & D )
static

Computes the barycentric coordinates for a given point on a tetrahedron (3D)

Parameters
Pointpoint to convert to barycentric coordinates
A,B,C,Dfour points defining a tetrahedron
Returns
Vector containing the four weights a,b,c,d such that Point = a*A + b*B + c*C + d*D

◆ ComputeBoundingSphereForCone() [1/2]

template<typename FReal >
FORCEINLINE UE::Math::TSphere< FReal > FMath::ComputeBoundingSphereForCone ( UE::Math::TVector< FReal > const & ConeOrigin,
UE::Math::TVector< FReal > const & ConeDirection,
FReal ConeRadius,
FReal CosConeAngle,
FReal SinConeAngle )

Computes minimal bounding sphere encompassing given cone

Definition at line 389 of file Sphere.h.

◆ ComputeBoundingSphereForCone() [2/2]

template<typename FReal >
static UE_NODISCARD UE::Math::TSphere< FReal > FMath::ComputeBoundingSphereForCone ( UE::Math::TVector< FReal > const & ConeOrigin,
UE::Math::TVector< FReal > const & ConeDirection,
FReal ConeRadius,
FReal CosConeAngle,
FReal SinConeAngle )
static

◆ ComputeProjectedSphereScissorRect()

static UE_NODISCARD uint32 FMath::ComputeProjectedSphereScissorRect ( FIntRect & InOutScissorRect,
FVector SphereOrigin,
float Radius,
FVector ViewOrigin,
const FMatrix & ViewMatrix,
const FMatrix & ProjMatrix )
static

◆ CriticallyDampedSmoothing()

template<class T >
static constexpr void FMath::CriticallyDampedSmoothing ( T & InOutValue,
T & InOutValueRate,
const T & InTargetValue,
const T & InTargetValueRate,
const float InDeltaTime,
const float InSmoothingTime )
inlinestaticconstexpr

Smooths a value using a critically damped spring. Works for any type that supports basic arithmetic operations.

Note that InSmoothingTime is the time lag when tracking constant motion (so if you tracked a predicted position TargetVel * InSmoothingTime ahead, you'd match the target position)

An approximation is used that is accurate so long as InDeltaTime < 0.5 * InSmoothingTime

When starting from zero velocity, the maximum velocity is reached after time InSmoothingTime * 0.5

Parameters
InOutValueThe value to be smoothed
InOutValueRateThe rate of change of the value
InTargetValueThe target to smooth towards
InTargetValueRateThe target rate of change smooth towards. Note that if this is discontinuous, then the output will have discontinuous velocity too.
InDeltaTimeTime interval
InSmoothingTimeTimescale over which to smooth. Larger values result in more smoothed behaviour. Can be zero.

Definition at line 1631 of file UnrealMathUtility.h.

◆ Cube()

template<class T >
static UE_NODISCARD constexpr FORCEINLINE T FMath::Cube ( const T A)
inlinestaticconstexpr

Cubes the value

Definition at line 581 of file UnrealMathUtility.h.

◆ CubicCRSplineInterp()

template<class U >
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE U FMath::CubicCRSplineInterp ( const U & P0,
const U & P1,
const U & P2,
const U & P3,
const float T0,
const float T1,
const float T2,
const float T3,
const float T )
inlinestaticconstexpr

Definition at line 1440 of file UnrealMathUtility.h.

◆ CubicCRSplineInterpSafe()

template<class U >
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE U FMath::CubicCRSplineInterpSafe ( const U & P0,
const U & P1,
const U & P2,
const U & P3,
const float T0,
const float T1,
const float T2,
const float T3,
const float T )
inlinestaticconstexpr

Definition at line 1460 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ CubicInterp() [1/2]

template<typename T , typename U UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE T FMath::CubicInterp ( const T & P0,
const T & T0,
const T & P1,
const T & T1,
const U & A )
inlinestaticconstexpr

Performs a cubic interpolation

Parameters
P- end points
T- tangent directions at end points
A- distance along spline
Returns
Interpolated value

Definition at line 1231 of file UnrealMathUtility.h.

◆ CubicInterp() [2/2]

template<typename T , typename U UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T FMath::CubicInterp ( const T & P0,
const T & T0,
const T & P1,
const T & T1,
const U & A )
inlinestatic

Custom lerps defined for those classes not suited to the default implemenation.

Definition at line 1247 of file UnrealMathUtility.h.

◆ CubicInterpDerivative()

template<typename T , typename U UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE T FMath::CubicInterpDerivative ( const T & P0,
const T & T0,
const T & P1,
const T & T1,
const U & A )
inlinestaticconstexpr

Performs a first derivative cubic interpolation

Parameters
P- end points
T- tangent directions at end points
A- distance along spline
Returns
Interpolated value

Definition at line 1268 of file UnrealMathUtility.h.

◆ CubicInterpSecondDerivative()

template<typename T , typename U UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE T FMath::CubicInterpSecondDerivative ( const T & P0,
const T & T0,
const T & P1,
const T & T1,
const U & A )
inlinestaticconstexpr

Performs a second derivative cubic interpolation

Parameters
P- end points
T- tangent directions at end points
A- distance along spline
Returns
Interpolated value

Definition at line 1295 of file UnrealMathUtility.h.

◆ DegreesToRadians() [1/3]

static FORCEINLINE double FMath::DegreesToRadians ( double const & DegVal)
inlinestatic

Definition at line 828 of file UnrealMathUtility.h.

◆ DegreesToRadians() [2/3]

static FORCEINLINE float FMath::DegreesToRadians ( float const & DegVal)
inlinestatic

Definition at line 827 of file UnrealMathUtility.h.

◆ DegreesToRadians() [3/3]

template<class T >
static UE_NODISCARD constexpr FORCEINLINE auto FMath::DegreesToRadians ( T const & DegVal) -> decltype(DegVal * (UE_PI / 180.f))
inlinestaticconstexpr

Converts degrees to radians.

Parameters
DegValValue in degrees.
Returns
Value in radians.

Definition at line 822 of file UnrealMathUtility.h.

◆ DivideAndRoundDown()

template<class T >
static UE_NODISCARD constexpr FORCEINLINE T FMath::DivideAndRoundDown ( T Dividend,
T Divisor )
inlinestaticconstexpr

Divides two integers and rounds down

Definition at line 645 of file UnrealMathUtility.h.

◆ DivideAndRoundNearest()

template<class T >
static UE_NODISCARD constexpr FORCEINLINE T FMath::DivideAndRoundNearest ( T Dividend,
T Divisor )
inlinestaticconstexpr

Divides two integers and rounds to nearest

Definition at line 652 of file UnrealMathUtility.h.

◆ DivideAndRoundUp()

template<class T >
static UE_NODISCARD constexpr FORCEINLINE T FMath::DivideAndRoundUp ( T Dividend,
T Divisor )
inlinestaticconstexpr

Divides two integers and rounds up

Definition at line 638 of file UnrealMathUtility.h.

◆ DynamicWeightedMovingAverage()

template<typename T >
static UE_NODISCARD T FMath::DynamicWeightedMovingAverage ( T CurrentSample,
T PreviousSample,
T MaxDistance,
T MinWeight,
T MaxWeight )
inlinestatic

Calculates the new value in a weighted moving average series using the previous value and a weight range. The weight range is used to dynamically adjust based upon distance between the samples This allows you to smooth a value more aggressively for small noise and let large movements be smoothed less (or vice versa)

Parameters
CurrentSample- The value to blend with the previous sample to get a new weighted value
PreviousSample- The last value from the series
MaxDistance- Distance to use as the blend between min weight or max weight
MinWeight- The weight use when the distance is small
MaxWeight- The weight use when the distance is large
Returns
the next value in the series

Definition at line 2518 of file UnrealMathUtility.h.

◆ Eval()

static bool FMath::Eval ( FString Str,
float & OutValue )
static

Evaluates a numerical equation.

Operators and precedence: 1:+- 2:/% 3:* 4:^ 5:&| Unary: - Types: Numbers (0-9.), Hex ($0-$f) Grouping: ( )

Parameters
StrString containing the equation.
OutValuePointer to storage for the result.
Returns
1 if successful, 0 if equation fails.

◆ ExponentialSmoothingApprox()

template<class T >
static constexpr void FMath::ExponentialSmoothingApprox ( T & InOutValue,
const T & InTargetValue,
const float InDeltaTime,
const float InSmoothingTime )
inlinestaticconstexpr

Smooths a value using exponential damping towards a target. Works for any type that supports basic arithmetic operations.

An approximation is used that is accurate so long as InDeltaTime < 0.5 * InSmoothingTime

Parameters
InOutValueThe value to be smoothed
InTargetValueThe target to smooth towards
InDeltaTimeTime interval
InSmoothingTimeTimescale over which to smooth. Larger values result in more smoothed behaviour. Can be zero.

Definition at line 1595 of file UnrealMathUtility.h.

◆ ExtractBoolFromBitfield()

static UE_NODISCARD constexpr bool FMath::ExtractBoolFromBitfield ( uint8 * Ptr,
uint32 Index )
inlinestaticconstexpr

Get a bit in memory created from bitflags (uint32 Value:1), used for EngineShowFlags, TestBitFieldFunctions() tests the implementation

Definition at line 2383 of file UnrealMathUtility.h.

◆ FastAsin() [1/2]

static UE_NODISCARD FORCEINLINE double FMath::FastAsin ( double Value)
inlinestatic

Definition at line 794 of file UnrealMathUtility.h.

◆ FastAsin() [2/2]

static UE_NODISCARD FORCEINLINE float FMath::FastAsin ( float Value)
inlinestatic

Computes the ASin of a scalar value.

Parameters
Valueinput angle
Returns
ASin of Value

Definition at line 775 of file UnrealMathUtility.h.

◆ FindDeltaAngleDegrees()

template<typename T , typename T2 UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr auto FMath::FindDeltaAngleDegrees ( T A1,
T2 A2 ) -> decltype(A1 * A2)
inlinestaticconstexpr

Find the smallest angle between two headings (in degrees)

Definition at line 850 of file UnrealMathUtility.h.

◆ FindDeltaAngleRadians()

template<typename T , typename T2 UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr auto FMath::FindDeltaAngleRadians ( T A1,
T2 A2 ) -> decltype(A1 * A2)
inlinestaticconstexpr

Find the smallest angle between two headings (in radians)

Definition at line 880 of file UnrealMathUtility.h.

◆ FInterpConstantTo()

template<typename T1 , typename T2 = T1, typename T3 = T2, typename T4 = T3>
static UE_NODISCARD auto FMath::FInterpConstantTo ( T1 Current,
T2 Target,
T3 DeltaTime,
T4 InterpSpeed )
inlinestatic

Interpolate float from Current to Target with constant step

Definition at line 1515 of file UnrealMathUtility.h.

◆ FInterpTo()

template<typename T1 , typename T2 = T1, typename T3 = T2, typename T4 = T3>
static UE_NODISCARD auto FMath::FInterpTo ( T1 Current,
T2 Target,
T3 DeltaTime,
T4 InterpSpeed )
inlinestatic

Interpolate float from Current to Target. Scaled by distance to Target, so it has a strong start speed and ease out.

Definition at line 1533 of file UnrealMathUtility.h.

◆ FixedTurn()

static UE_NODISCARD float FMath::FixedTurn ( float InCurrent,
float InDesired,
float InDeltaRate )
static

Returns a new rotation component value

Parameters
InCurrentis the current rotation value
InDesiredis the desired rotation value
InDeltaRateis the rotation amount to apply
Returns
a new rotation component value

◆ Floor() [1/3]

static UE_NODISCARD FORCEINLINE double FMath::Floor ( double F)
inlinestatic

Converts a double to a nearest less or equal integer.

Definition at line 522 of file UnrealMathUtility.h.

◆ Floor() [2/3]

static UE_NODISCARD FORCEINLINE float FMath::Floor ( float F)
inlinestatic

Converts a float to a nearest less or equal integer.

Definition at line 516 of file UnrealMathUtility.h.

◆ Floor() [3/3]

template<typename IntegralType UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr FORCEINLINE IntegralType FMath::Floor ( IntegralType I)
inlinestaticconstexpr

Converts an integral type to a nearest less or equal integer. Unlike std::floor, it returns an IntegralType.

Definition at line 537 of file UnrealMathUtility.h.

◆ FormatIntToHumanReadable()

static UE_NODISCARD FString FMath::FormatIntToHumanReadable ( int32 Val)
static

Formats an integer value into a human readable string (i.e. 12345 becomes "12,345")

Parameters
ValThe value to use
Returns
FString The human readable string

◆ FRandRange() [1/2]

static UE_NODISCARD FORCEINLINE double FMath::FRandRange ( double InMin,
double InMax )
inlinestatic

Util to generate a random number in a range.

Definition at line 310 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

◆ FRandRange() [2/2]

static UE_NODISCARD FORCEINLINE float FMath::FRandRange ( float InMin,
float InMax )
inlinestatic

Util to generate a random number in a range.

Definition at line 304 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

◆ GetAzimuthAndElevation()

static UE_NODISCARD FVector2D FMath::GetAzimuthAndElevation ( const FVector & Direction,
const FVector & AxisX,
const FVector & AxisY,
const FVector & AxisZ )
static

Returns Azimuth and Elevation of vector 'Direction' in coordinate system O(AxisX,AxisY,AxisZ).

Orientation: (consider 'O' the first person view of the player, and 'Direction' a vector pointing to an enemy)

  • positive azimuth means enemy is on the right of crosshair. (negative means left).
  • positive elevation means enemy is on top of crosshair, negative means below.
Parameters
DirectionDirection of target.
AxisXX component of reference system.
AxisYY component of reference system.
AxisZZ component of reference system.
Returns
FVector2D X = Azimuth angle (in radians) (-PI, +PI) Y = Elevation angle (in radians) (-PI/2, +PI/2)

◆ GetBaryCentric2D() [1/2]

static UE_NODISCARD FVector FMath::GetBaryCentric2D ( const FVector & Point,
const FVector & A,
const FVector & B,
const FVector & C )
static

Computes the barycentric coordinates for a given point in a triangle, only considering the XY coordinates - simpler than the Compute versions

Parameters
Pointpoint to convert to barycentric coordinates (in plane of ABC)
A,B,Cthree non-collinear points defining a triangle in CCW
Returns
Vector containing the three weights a,b,c such that Point = a*A + b*B + c*C or Point = A + b*(B-A) + c*(C-A) = (1-b-c)*A + b*B + c*C

◆ GetBaryCentric2D() [2/2]

static UE_NODISCARD FVector FMath::GetBaryCentric2D ( const FVector2D & Point,
const FVector2D & A,
const FVector2D & B,
const FVector2D & C )
static

Computes the barycentric coordinates for a given point in a triangle - simpler than the Compute versions

Parameters
Pointpoint to convert to barycentric coordinates (in plane of ABC)
A,B,Cthree non-collinear points defining a triangle in CCW
Returns
Vector containing the three weights a,b,c such that Point = a*A + b*B + c*C or Point = A + b*(B-A) + c*(C-A) = (1-b-c)*A + b*B + c*C

◆ GetDistanceWithinConeSegment()

static UE_NODISCARD bool FMath::GetDistanceWithinConeSegment ( FVector Point,
FVector ConeStartPoint,
FVector ConeLine,
float RadiusAtStart,
float RadiusAtEnd,
float & PercentageOut )
static

Calculates whether a Point is within a cone segment, and also what percentage within the cone (100% is along the center line, whereas 0% is along the edge)

Parameters
Point- The Point in question
ConeStartPoint- the beginning of the cone (with the smallest radius)
ConeLine- the line out from the start point that ends at the largest radius point of the cone
RadiusAtStart- the radius at the ConeStartPoint (0 for a 'proper' cone)
RadiusAtEnd- the largest radius of the cone
PercentageOut- output variable the holds how much within the cone the point is (1 = on center line, 0 = on exact edge or outside cone).
Returns
true if the point is within the cone, false otherwise.

◆ GetDotDistance()

static bool FMath::GetDotDistance ( FVector2D & OutDotDist,
const FVector & Direction,
const FVector & AxisX,
const FVector & AxisY,
const FVector & AxisZ )
static

Calculates the dotted distance of vector 'Direction' to coordinate system O(AxisX,AxisY,AxisZ).

Orientation: (consider 'O' the first person view of the player, and 'Direction' a vector pointing to an enemy)

  • positive azimuth means enemy is on the right of crosshair. (negative means left).
  • positive elevation means enemy is on top of crosshair, negative means below.

@Note: 'Azimuth' (.X) sign is changed to represent left/right and not front/behind. front/behind is the funtion's return value.

Parameters
OutDotDist.X = 'Direction' dot AxisX relative to plane (AxisX,AxisZ). (== Cos(Azimuth)) .Y = 'Direction' dot AxisX relative to plane (AxisX,AxisY). (== Sin(Elevation))
Directiondirection of target.
AxisXX component of reference system.
AxisYY component of reference system.
AxisZZ component of reference system.
Returns
true if 'Direction' is facing AxisX (Direction dot AxisX >= 0.f)

◆ GetMappedRangeValueClamped() [1/2]

template<class T >
static UE_NODISCARD FORCEINLINE T FMath::GetMappedRangeValueClamped ( const TRange< T > & InputRange,
const TRange< T > & OutputRange,
const T Value )
inlinestatic

Definition at line 1109 of file UnrealMathUtility.h.

◆ GetMappedRangeValueClamped() [2/2]

template<typename T , typename T2 >
static UE_NODISCARD FORCEINLINE auto FMath::GetMappedRangeValueClamped ( const UE::Math::TVector2< T > & InputRange,
const UE::Math::TVector2< T > & OutputRange,
const T2 Value )
inlinestatic

For the given Value clamped to the [Input:Range] inclusive, returns the corresponding percentage in [Output:Range] Inclusive.

Definition at line 1082 of file UnrealMathUtility.h.

◆ GetMappedRangeValueUnclamped()

template<typename T , typename T2 >
static UE_NODISCARD FORCEINLINE auto FMath::GetMappedRangeValueUnclamped ( const UE::Math::TVector2< T > & InputRange,
const UE::Math::TVector2< T > & OutputRange,
const T2 Value )
inlinestatic

Transform the given Value relative to the input range to the Output Range.

Definition at line 1091 of file UnrealMathUtility.h.

◆ GetRangePct() [1/3]

template<typename T , typename T2 UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr FORCEINLINE auto FMath::GetRangePct ( T MinValue,
T MaxValue,
T2 Value )
inlinestaticconstexpr

Calculates the percentage along a line from MinValue to MaxValue that Value is.

Definition at line 1040 of file UnrealMathUtility.h.

◆ GetRangePct() [2/3]

template<class T >
static UE_NODISCARD FORCEINLINE double FMath::GetRangePct ( TRange< T > const & Range,
T Value )
inlinestatic

Definition at line 1097 of file UnrealMathUtility.h.

◆ GetRangePct() [3/3]

template<typename T , typename T2 UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD auto FMath::GetRangePct ( UE::Math::TVector2< T > const & Range,
T2 Value )
inlinestatic

Same as above, but taking a 2d vector as the range.

Definition at line 1062 of file UnrealMathUtility.h.

◆ GetRangeValue() [1/2]

template<class T >
static UE_NODISCARD FORCEINLINE T FMath::GetRangeValue ( TRange< T > const & Range,
T Pct )
inlinestatic

Definition at line 1103 of file UnrealMathUtility.h.

◆ GetRangeValue() [2/2]

template<typename T , typename T2 UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD auto FMath::GetRangeValue ( UE::Math::TVector2< T > const & Range,
T2 Pct )
inlinestatic

Basically a Vector2d version of Lerp.

Definition at line 1075 of file UnrealMathUtility.h.

◆ GetReflectionVector()

static UE_NODISCARD FVector FMath::GetReflectionVector ( const FVector & Direction,
const FVector & SurfaceNormal )
static

Given a direction vector and a surface normal, returns the vector reflected across the surface normal. Produces a result like shining a laser at a mirror!

Parameters
DirectionDirection vector the ray is coming from.
SurfaceNormalA normal of the surface the ray should be reflected on.
Returns
Reflected vector.

◆ GetTForSegmentPlaneIntersect()

static UE_NODISCARD float FMath::GetTForSegmentPlaneIntersect ( const FVector & StartPoint,
const FVector & EndPoint,
const FPlane & Plane )
static

returns the time (t) of the intersection of the passed segment and a plane (could be <0 or >1)

Parameters
StartPoint- start point of segment
EndPoint- end point of segment
Plane- plane to intersect with
Returns
time(T) of intersection

◆ GreatestCommonDivisor()

static UE_NODISCARD constexpr int32 FMath::GreatestCommonDivisor ( int32 a,
int32 b )
inlinestaticconstexpr

Definition at line 2440 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

◆ GridSnap()

template<class T >
static UE_NODISCARD constexpr FORCEINLINE T FMath::GridSnap ( T Location,
T Grid )
inlinestaticconstexpr

Snaps a value to the nearest grid multiple

Definition at line 629 of file UnrealMathUtility.h.

◆ InterpCircularIn()

template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T FMath::InterpCircularIn ( const T & A,
const T & B,
float Alpha )
inlinestatic

Interpolation between A and B, applying a circular in function.

Definition at line 1399 of file UnrealMathUtility.h.

◆ InterpCircularInOut()

template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T FMath::InterpCircularInOut ( const T & A,
const T & B,
float Alpha )
inlinestatic

Interpolation between A and B, applying a circular in/out function.

Definition at line 1416 of file UnrealMathUtility.h.

◆ InterpCircularOut()

template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T FMath::InterpCircularOut ( const T & A,
const T & B,
float Alpha )
inlinestatic

Interpolation between A and B, applying a circular out function.

Definition at line 1407 of file UnrealMathUtility.h.

◆ InterpEaseIn()

template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T FMath::InterpEaseIn ( const T & A,
const T & B,
float Alpha,
float Exp )
inlinestatic

Interpolate between A and B, applying an ease in function. Exp controls the degree of the curve.

Definition at line 1305 of file UnrealMathUtility.h.

◆ InterpEaseInOut()

template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T FMath::InterpEaseInOut ( const T & A,
const T & B,
float Alpha,
float Exp )
inlinestatic

Interpolate between A and B, applying an ease in/out function. Exp controls the degree of the curve.

Definition at line 1321 of file UnrealMathUtility.h.

◆ InterpEaseOut()

template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T FMath::InterpEaseOut ( const T & A,
const T & B,
float Alpha,
float Exp )
inlinestatic

Interpolate between A and B, applying an ease out function. Exp controls the degree of the curve.

Definition at line 1313 of file UnrealMathUtility.h.

◆ InterpExpoIn()

template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T FMath::InterpExpoIn ( const T & A,
const T & B,
float Alpha )
inlinestatic

Interpolation between A and B, applying an exponential in function.

Definition at line 1374 of file UnrealMathUtility.h.

◆ InterpExpoInOut()

template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T FMath::InterpExpoInOut ( const T & A,
const T & B,
float Alpha )
inlinestatic

Interpolation between A and B, applying an exponential in/out function.

Definition at line 1390 of file UnrealMathUtility.h.

◆ InterpExpoOut()

template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T FMath::InterpExpoOut ( const T & A,
const T & B,
float Alpha )
inlinestatic

Interpolation between A and B, applying an exponential out function.

Definition at line 1382 of file UnrealMathUtility.h.

◆ InterpSinIn()

template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T FMath::InterpSinIn ( const T & A,
const T & B,
float Alpha )
inlinestatic

Interpolation between A and B, applying a sinusoidal in function.

Definition at line 1349 of file UnrealMathUtility.h.

◆ InterpSinInOut()

template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T FMath::InterpSinInOut ( const T & A,
const T & B,
float Alpha )
inlinestatic

Interpolation between A and B, applying a sinusoidal in/out function.

Definition at line 1365 of file UnrealMathUtility.h.

◆ InterpSinOut()

template<class T >
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T FMath::InterpSinOut ( const T & A,
const T & B,
float Alpha )
inlinestatic

Interpolation between A and B, applying a sinusoidal out function.

Definition at line 1357 of file UnrealMathUtility.h.

◆ InterpStep()

template<class T >
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE T FMath::InterpStep ( const T & A,
const T & B,
float Alpha,
int32 Steps )
inlinestaticconstexpr

Interpolation between A and B, applying a step function.

Definition at line 1330 of file UnrealMathUtility.h.

◆ IntersectPlanes2() [1/2]

template<typename FReal >
static UE_NODISCARD bool FMath::IntersectPlanes2 ( UE::Math::TVector< FReal > & I,
UE::Math::TVector< FReal > & D,
const UE::Math::TPlane< FReal > & P1,
const UE::Math::TPlane< FReal > & P2 )
static

Compute intersection point and direction of line joining two planes. Return 1 if valid, 0 if infinite.

◆ IntersectPlanes2() [2/2]

template<typename T >
bool FMath::IntersectPlanes2 ( UE::Math::TVector< T > & I,
UE::Math::TVector< T > & D,
const UE::Math::TPlane< T > & P1,
const UE::Math::TPlane< T > & P2 )
inline

Definition at line 685 of file Plane.h.

◆ IntersectPlanes3() [1/2]

template<typename FReal >
static UE_NODISCARD bool FMath::IntersectPlanes3 ( UE::Math::TVector< FReal > & I,
const UE::Math::TPlane< FReal > & P1,
const UE::Math::TPlane< FReal > & P2,
const UE::Math::TPlane< FReal > & P3 )
static

Compute intersection point of three planes. Return 1 if valid, 0 if infinite.

◆ IntersectPlanes3() [2/2]

template<typename T >
bool FMath::IntersectPlanes3 ( UE::Math::TVector< T > & I,
const UE::Math::TPlane< T > & P1,
const UE::Math::TPlane< T > & P2,
const UE::Math::TPlane< T > & P3 )
inline

Definition at line 666 of file Plane.h.

◆ InvExpApprox()

template<class T >
static UE_NODISCARD constexpr T FMath::InvExpApprox ( T X)
inlinestaticconstexpr

Returns an approximation of Exp(-X) based on a Taylor expansion that has had the coefficients adjusted (using optimisation) to minimise the error in the range 0 < X < 1, which is below 0.1%. Note that it returns exactly 1 when X is 0, and the return value is greater than the real value for values of X > 1 (but it still tends to zero for large X).

Definition at line 1576 of file UnrealMathUtility.h.

◆ IsNearlyEqual() [1/2]

static UE_NODISCARD FORCEINLINE bool FMath::IsNearlyEqual ( double A,
double B,
double ErrorTolerance = UE_DOUBLE_SMALL_NUMBER )
inlinestatic

Definition at line 384 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

◆ IsNearlyEqual() [2/2]

static UE_NODISCARD FORCEINLINE bool FMath::IsNearlyEqual ( float A,
float B,
float ErrorTolerance = UE_SMALL_NUMBER )
inlinestatic

Checks if two floating point numbers are nearly equal.

Parameters
AFirst number to compare
BSecond number to compare
ErrorToleranceMaximum allowed difference for considering them as 'nearly equal'
Returns
true if A and B are nearly equal

Definition at line 379 of file UnrealMathUtility.h.

◆ IsNearlyEqualByULP() [1/2]

static UE_NODISCARD FORCEINLINE bool FMath::IsNearlyEqualByULP ( double A,
double B,
int32 MaxUlps = 4 )
inlinestatic

Check if two floating point numbers are nearly equal to within specific number of units of last place (ULP). A single ULP difference between two floating point numbers means that they have an adjacent representation and that no other floating point number can be constructed to fit between them. This enables making consistent comparisons based on representational distance between floating point numbers, regardless of their magnitude.

Note: Since IEEE 754 floating point operations are guaranteed to be exact to 0.5 ULP, a value of 4 ought to be sufficient for all but the most complex float operations.

Parameters
AFirst number to compare
BSecond number to compare
MaxUlpsThe maximum ULP distance by which neighboring floating point numbers are allowed to differ.
Returns
true if the two values are nearly equal.

Definition at line 499 of file UnrealMathUtility.h.

◆ IsNearlyEqualByULP() [2/2]

static UE_NODISCARD FORCEINLINE bool FMath::IsNearlyEqualByULP ( float A,
float B,
int32 MaxUlps = 4 )
inlinestatic

Check if two floating point numbers are nearly equal to within specific number of units of last place (ULP). A single ULP difference between two floating point numbers means that they have an adjacent representation and that no other floating point number can be constructed to fit between them. This enables making consistent comparisons based on representational distance between floating point numbers, regardless of their magnitude.

Use when the two numbers vary greatly in range. Otherwise, if absolute tolerance is required, use IsNearlyEqual instead.

Note: Since IEEE 754 floating point operations are guaranteed to be exact to 0.5 ULP, a value of 4 ought to be sufficient for all but the most complex float operations.

Parameters
AFirst number to compare
BSecond number to compare
MaxUlpsThe maximum ULP distance by which neighboring floating point numbers are allowed to differ.
Returns
true if the two values are nearly equal.

Definition at line 477 of file UnrealMathUtility.h.

◆ IsNearlyZero() [1/2]

static UE_NODISCARD FORCEINLINE bool FMath::IsNearlyZero ( double Value,
double ErrorTolerance = UE_DOUBLE_SMALL_NUMBER )
inlinestatic

Checks if a floating point number is nearly zero.

Parameters
ValueNumber to compare
ErrorToleranceMaximum allowed difference for considering Value as 'nearly zero'
Returns
true if Value is nearly zero

Definition at line 409 of file UnrealMathUtility.h.

◆ IsNearlyZero() [2/2]

static UE_NODISCARD FORCEINLINE bool FMath::IsNearlyZero ( float Value,
float ErrorTolerance = UE_SMALL_NUMBER )
inlinestatic

Checks if a floating point number is nearly zero.

Parameters
ValueNumber to compare
ErrorToleranceMaximum allowed difference for considering Value as 'nearly zero'
Returns
true if Value is nearly zero

Definition at line 398 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

◆ IsPowerOfTwo()

template<typename T >
static UE_NODISCARD constexpr FORCEINLINE bool FMath::IsPowerOfTwo ( T Value)
inlinestaticconstexpr

Checks whether a number is a power of two.

Parameters
ValueNumber to check
Returns
true if Value is a power of two

Definition at line 510 of file UnrealMathUtility.h.

◆ IsWithin()

template<class T , class U >
static UE_NODISCARD constexpr FORCEINLINE bool FMath::IsWithin ( const T & TestValue,
const U & MinValue,
const U & MaxValue )
inlinestaticconstexpr

Checks if value is within a range, exclusive on MaxValue)

Definition at line 359 of file UnrealMathUtility.h.

◆ IsWithinInclusive()

template<class T , class U >
static UE_NODISCARD constexpr FORCEINLINE bool FMath::IsWithinInclusive ( const T & TestValue,
const U & MinValue,
const U & MaxValue )
inlinestaticconstexpr

Checks if value is within a range, inclusive on MaxValue)

Definition at line 367 of file UnrealMathUtility.h.

◆ LeastCommonMultiplier()

static UE_NODISCARD constexpr int32 FMath::LeastCommonMultiplier ( int32 a,
int32 b )
inlinestaticconstexpr

Definition at line 2453 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ Lerp() [1/3]

template<typename T , typename U UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE T FMath::Lerp ( const T & A,
const T & B,
const U & Alpha )
inlinestaticconstexpr

Performs a linear interpolation between two values, Alpha ranges from 0-1

Definition at line 1123 of file UnrealMathUtility.h.

◆ Lerp() [2/3]

template<typename T , typename U UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD FORCEINLINE_DEBUGGABLE T FMath::Lerp ( const T & A,
const T & B,
const U & Alpha )
inlinestatic

Custom lerps defined for those classes not suited to the default implemenation.

Definition at line 1136 of file UnrealMathUtility.h.

◆ Lerp() [3/3]

template<typename T1 , typename T2 , typename T3 UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD auto FMath::Lerp ( const T1 & A,
const T2 & B,
const T3 & Alpha ) -> decltype(A * B)
inlinestatic

Definition at line 1150 of file UnrealMathUtility.h.

◆ LerpRange() [1/2]

template<typename T , typename U >
FORCEINLINE_DEBUGGABLE UE::Math::TRotator< T > FMath::LerpRange ( const UE::Math::TRotator< T > & A,
const UE::Math::TRotator< T > & B,
U Alpha )

Definition at line 913 of file Rotator.h.

◆ LerpRange() [2/2]

template<typename T , typename U >
static UE_NODISCARD UE::Math::TRotator< T > FMath::LerpRange ( const UE::Math::TRotator< T > & A,
const UE::Math::TRotator< T > & B,
U Alpha )
static

◆ LerpStable() [1/3]

template<class T >
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE T FMath::LerpStable ( const T & A,
const T & B,
double Alpha )
inlinestaticconstexpr

Performs a linear interpolation between two values, Alpha ranges from 0-1. Handles full numeric range of T

Definition at line 1158 of file UnrealMathUtility.h.

◆ LerpStable() [2/3]

template<class T >
static UE_NODISCARD constexpr FORCEINLINE_DEBUGGABLE T FMath::LerpStable ( const T & A,
const T & B,
float Alpha )
inlinestaticconstexpr

Performs a linear interpolation between two values, Alpha ranges from 0-1. Handles full numeric range of T

Definition at line 1165 of file UnrealMathUtility.h.

◆ LerpStable() [3/3]

template<typename T1 , typename T2 , typename T3 UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD auto FMath::LerpStable ( const T1 & A,
const T2 & B,
const T3 & Alpha ) -> decltype(A * B)
inlinestatic

Definition at line 1179 of file UnrealMathUtility.h.

◆ LineBoxIntersection() [1/4]

template<typename FReal >
static UE_NODISCARD bool FMath::LineBoxIntersection ( const UE::Math::TBox< FReal > & Box,
const UE::Math::TVector< FReal > & Start,
const UE::Math::TVector< FReal > & End,
const UE::Math::TVector< FReal > & Direction )
static

Determines whether a line intersects a box.

◆ LineBoxIntersection() [2/4]

template<typename FReal >
static UE_NODISCARD bool FMath::LineBoxIntersection ( const UE::Math::TBox< FReal > & Box,
const UE::Math::TVector< FReal > & Start,
const UE::Math::TVector< FReal > & End,
const UE::Math::TVector< FReal > & Direction,
const UE::Math::TVector< FReal > & OneOverDirection )
static

Determines whether a line intersects a box. This overload avoids the need to do the reciprocal every time.

◆ LineBoxIntersection() [3/4]

template<typename FReal >
bool FMath::LineBoxIntersection ( const UE::Math::TBox< FReal > & Box,
const UE::Math::TVector< FReal > & Start,
const UE::Math::TVector< FReal > & End,
const UE::Math::TVector< FReal > & StartToEnd )
inline

Definition at line 862 of file Box.h.

◆ LineBoxIntersection() [4/4]

template<typename FReal >
bool FMath::LineBoxIntersection ( const UE::Math::TBox< FReal > & Box,
const UE::Math::TVector< FReal > & Start,
const UE::Math::TVector< FReal > & End,
const UE::Math::TVector< FReal > & StartToEnd,
const UE::Math::TVector< FReal > & OneOverStartToEnd )
inline

Definition at line 874 of file Box.h.

◆ LineExtentBoxIntersection()

static bool FMath::LineExtentBoxIntersection ( const FBox & inBox,
const FVector & Start,
const FVector & End,
const FVector & Extent,
FVector & HitLocation,
FVector & HitNormal,
float & HitTime )
static

◆ LinePlaneIntersection() [1/4]

template<typename FReal >
static UE_NODISCARD UE::Math::TVector< FReal > FMath::LinePlaneIntersection ( const UE::Math::TVector< FReal > & Point1,
const UE::Math::TVector< FReal > & Point2,
const UE::Math::TPlane< FReal > & Plane )
static

Find the intersection of a line and a plane. Assumes that the line and plane do indeed intersect; you must make sure they're not parallel before calling.

Parameters
Point1the first point defining the line
Point2the second point defining the line
Planethe plane
Returns
The point of intersection between the line and the plane.

◆ LinePlaneIntersection() [2/4]

template<typename FReal >
static UE_NODISCARD UE::Math::TVector< FReal > FMath::LinePlaneIntersection ( const UE::Math::TVector< FReal > & Point1,
const UE::Math::TVector< FReal > & Point2,
const UE::Math::TVector< FReal > & PlaneOrigin,
const UE::Math::TVector< FReal > & PlaneNormal )
static

Find the intersection of a line and an offset plane. Assumes that the line and plane do indeed intersect; you must make sure they're not parallel before calling.

Parameters
Point1the first point defining the line
Point2the second point defining the line
PlaneOriginthe origin of the plane
PlaneNormalthe normal of the plane
Returns
The point of intersection between the line and the plane.

◆ LinePlaneIntersection() [3/4]

template<typename T >
UE::Math::TVector< T > FMath::LinePlaneIntersection ( const UE::Math::TVector< T > & Point1,
const UE::Math::TVector< T > & Point2,
const UE::Math::TPlane< T > & Plane )
inline

Definition at line 652 of file Plane.h.

◆ LinePlaneIntersection() [4/4]

template<typename T >
UE::Math::TVector< T > FMath::LinePlaneIntersection ( const UE::Math::TVector< T > & Point1,
const UE::Math::TVector< T > & Point2,
const UE::Math::TVector< T > & PlaneOrigin,
const UE::Math::TVector< T > & PlaneNormal )
inline

Definition at line 2587 of file Vector.h.

◆ LineSphereIntersection() [1/2]

template<typename FReal >
static UE_NODISCARD bool FMath::LineSphereIntersection ( const UE::Math::TVector< FReal > & Start,
const UE::Math::TVector< FReal > & Dir,
FReal Length,
const UE::Math::TVector< FReal > & Origin,
FReal Radius )
static

Determines whether a line intersects a sphere.

◆ LineSphereIntersection() [2/2]

template<typename T >
bool FMath::LineSphereIntersection ( const UE::Math::TVector< T > & Start,
const UE::Math::TVector< T > & Dir,
T Length,
const UE::Math::TVector< T > & Origin,
T Radius )
inline

Definition at line 2602 of file Vector.h.

◆ Log2() [1/2]

static UE_NODISCARD FORCEINLINE double FMath::Log2 ( double Value)
inlinestatic

Computes the base 2 logarithm of the specified value

Parameters
Valuethe value to perform the log on
Returns
the base 2 log of the value

Definition at line 681 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

◆ Log2() [2/2]

static UE_NODISCARD FORCEINLINE float FMath::Log2 ( float Value)
inlinestatic

Computes the base 2 logarithm of the specified value

Parameters
Valuethe value to perform the log on
Returns
the base 2 log of the value

Definition at line 666 of file UnrealMathUtility.h.

◆ MakePulsatingValue()

static UE_NODISCARD float FMath::MakePulsatingValue ( const double InCurrentTime,
const float InPulsesPerSecond,
const float InPhase = 0.0f )
inlinestatic

Simple function to create a pulsating scalar value

Parameters
InCurrentTimeCurrent absolute time
InPulsesPerSecondHow many full pulses per second?
InPhaseOptional phase amount, between 0.0 and 1.0 (to synchronize pulses)
Returns
Pulsating value (0.0-1.0)

Definition at line 1828 of file UnrealMathUtility.h.

◆ Max3()

template<class T >
static UE_NODISCARD constexpr FORCEINLINE T FMath::Max3 ( const T A,
const T B,
const T C )
inlinestaticconstexpr

Returns highest of 3 values

Definition at line 547 of file UnrealMathUtility.h.

◆ Max3Index()

template<class T >
static UE_NODISCARD constexpr FORCEINLINE int32 FMath::Max3Index ( const T A,
const T B,
const T C )
inlinestaticconstexpr

Definition at line 560 of file UnrealMathUtility.h.

◆ MemoryTest()

static UE_NODISCARD bool FMath::MemoryTest ( void * BaseAddress,
uint32 NumBytes )
static

Tests a memory region to see that it's working properly.

Parameters
BaseAddressStarting address
NumBytesNumber of bytes to test (will be rounded down to a multiple of 4)
Returns
true if the memory region passed the test

◆ Min3()

template<class T >
static UE_NODISCARD constexpr FORCEINLINE T FMath::Min3 ( const T A,
const T B,
const T C )
inlinestaticconstexpr

Returns lowest of 3 values

Definition at line 554 of file UnrealMathUtility.h.

◆ Min3Index()

template<class T >
static UE_NODISCARD constexpr FORCEINLINE int32 FMath::Min3Index ( const T A,
const T B,
const T C )
inlinestaticconstexpr

Returns index of the lowest value

Definition at line 567 of file UnrealMathUtility.h.

◆ MIX_FLOATS_2_ARGS()

FMath::MIX_FLOATS_2_ARGS ( GridSnap )

Allow mixing float/double arguments, promoting to highest precision type.

◆ MIX_FLOATS_3_ARGS()

FMath::MIX_FLOATS_3_ARGS ( Clamp )

Allow mixing float/double arguments, promoting to highest precision type.

◆ PerlinNoise1D()

static UE_NODISCARD float FMath::PerlinNoise1D ( float Value)
static

Generates a 1D Perlin noise from the given value. Returns a continuous random value between -1.0 and 1.0.

Parameters
ValueThe input value that Perlin noise will be generated from. This is usually a steadily incrementing time value.
Returns
Perlin noise in the range of -1.0 to 1.0

◆ PerlinNoise2D()

static UE_NODISCARD float FMath::PerlinNoise2D ( const FVector2D & Location)
static

Generates a 1D Perlin noise sample at the given location. Returns a continuous random value between -1.0 and 1.0.

Parameters
LocationWhere to sample
Returns
Perlin noise in the range of -1.0 to 1.0

◆ PerlinNoise3D()

static UE_NODISCARD float FMath::PerlinNoise3D ( const FVector & Location)
static

Generates a 3D Perlin noise sample at the given location. Returns a continuous random value between -1.0 and 1.0.

Parameters
LocationWhere to sample
Returns
Perlin noise in the range of -1.0 to 1.0

◆ PlaneAABBIntersection()

static UE_NODISCARD bool FMath::PlaneAABBIntersection ( const FPlane & P,
const FBox & AABB )
static

Determine if a plane and an AABB intersect

Parameters
P- the plane to test
AABB- the axis aligned bounding box to test
Returns
if collision occurs

◆ PlaneAABBRelativePosition()

static UE_NODISCARD int32 FMath::PlaneAABBRelativePosition ( const FPlane & P,
const FBox & AABB )
static

Determine the position of an AABB relative to a plane: completely above (in the direction of the normal of the plane), completely below or intersects it

Parameters
P- the plane to test
AABB- the axis aligned bounding box to test
Returns
-1 if below, 1 if above, 0 if intersects

◆ PointBoxIntersection() [1/2]

template<typename FReal >
bool FMath::PointBoxIntersection ( const UE::Math::TVector< FReal > & Point,
const UE::Math::TBox< FReal > & Box )
inline

Definition at line 850 of file Box.h.

◆ PointBoxIntersection() [2/2]

template<typename FReal >
static UE_NODISCARD bool FMath::PointBoxIntersection ( const UE::Math::TVector< FReal > & Point,
const UE::Math::TBox< FReal > & Box )
static

Determines whether a point is inside a box.

◆ PointDistToLine() [1/2]

static UE_NODISCARD float FMath::PointDistToLine ( const FVector & Point,
const FVector & Direction,
const FVector & Origin )
static

◆ PointDistToLine() [2/2]

static float FMath::PointDistToLine ( const FVector & Point,
const FVector & Direction,
const FVector & Origin,
FVector & OutClosestPoint )
static

Calculates the distance of a given Point in world space to a given line, defined by the vector couple (Origin, Direction).

Parameters
PointPoint to check distance to line
DirectionVector indicating the direction of the line. Not required to be normalized.
OriginPoint of reference used to calculate distance
OutClosestPointoptional point that represents the closest point projected onto Axis
Returns
distance of Point from line defined by (Origin, Direction)

◆ PointDistToSegment()

static UE_NODISCARD float FMath::PointDistToSegment ( const FVector & Point,
const FVector & StartPoint,
const FVector & EndPoint )
static

Returns distance from a point to the closest point on a segment.

Parameters
Pointpoint to check distance for
StartPointStartPoint of segment
EndPointEndPoint of segment
Returns
closest distance from Point to segment defined by (StartPoint, EndPoint).

◆ PointDistToSegmentSquared()

static UE_NODISCARD float FMath::PointDistToSegmentSquared ( const FVector & Point,
const FVector & StartPoint,
const FVector & EndPoint )
static

Returns square of the distance from a point to the closest point on a segment.

Parameters
Pointpoint to check distance for
StartPointStartPoint of segment
EndPointEndPoint of segment
Returns
square of the closest distance from Point to segment defined by (StartPoint, EndPoint).

◆ PointsAreCoplanar()

static UE_NODISCARD bool FMath::PointsAreCoplanar ( const TArray< FVector > & Points,
const float Tolerance = 0.1f )
static

Determines whether a given set of points are coplanar, with a tolerance. Any three points or less are always coplanar.

Parameters
Points- The set of points to determine coplanarity for.
Tolerance- Larger numbers means more variance is allowed.
Returns
Whether the points are relatively coplanar, based on the tolerance

◆ PolarToCartesian() [1/2]

template<typename T >
static FORCEINLINE void FMath::PolarToCartesian ( const T Rad,
const T Ang,
T & OutX,
T & OutY )
inlinestatic

Converts given Polar coordinate pair to Cartesian coordinate system.

Definition at line 981 of file UnrealMathUtility.h.

◆ PolarToCartesian() [2/2]

template<typename T >
static FORCEINLINE void FMath::PolarToCartesian ( const UE::Math::TVector2< T > InPolar,
UE::Math::TVector2< T > & OutCart )
inlinestatic

Converts given Polar coordinate pair to Cartesian coordinate system.

Definition at line 988 of file UnrealMathUtility.h.

◆ QInterpConstantTo()

template<class T >
static UE_NODISCARD UE::Math::TQuat< T > FMath::QInterpConstantTo ( const UE::Math::TQuat< T > & Current,
const UE::Math::TQuat< T > & Target,
float DeltaTime,
float InterpSpeed )
static

Interpolate quaternion from Current to Target with constant step (in radians)

◆ QInterpTo()

template<class T >
static UE_NODISCARD UE::Math::TQuat< T > FMath::QInterpTo ( const UE::Math::TQuat< T > & Current,
const UE::Math::TQuat< T > & Target,
float DeltaTime,
float InterpSpeed )
static

Interpolate quaternion from Current to Target. Scaled by angle to Target, so it has a strong start speed and ease out.

◆ Quantize8SignedByte()

static UE_NODISCARD uint8 FMath::Quantize8SignedByte ( float x)
inlinestatic

Definition at line 2431 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ Quantize8UnsignedByte()

static UE_NODISCARD uint8 FMath::Quantize8UnsignedByte ( float x)
inlinestatic

Definition at line 2418 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

◆ RadiansToDegrees() [1/3]

static FORCEINLINE double FMath::RadiansToDegrees ( double const & RadVal)
inlinestatic

Definition at line 814 of file UnrealMathUtility.h.

◆ RadiansToDegrees() [2/3]

static FORCEINLINE float FMath::RadiansToDegrees ( float const & RadVal)
inlinestatic

Definition at line 813 of file UnrealMathUtility.h.

◆ RadiansToDegrees() [3/3]

template<class T >
static UE_NODISCARD constexpr FORCEINLINE auto FMath::RadiansToDegrees ( T const & RadVal) -> decltype(RadVal * (180.f / UE_PI))
inlinestaticconstexpr

Converts radians to degrees.

Parameters
RadValValue in radians.
Returns
Value in degrees.

Definition at line 808 of file UnrealMathUtility.h.

◆ RandBool()

static UE_NODISCARD FORCEINLINE bool FMath::RandBool ( )
inlinestatic

Util to generate a random boolean.

Definition at line 318 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ RandHelper()

static UE_NODISCARD FORCEINLINE int32 FMath::RandHelper ( int32 A)
inlinestatic

Helper function for rand implementations. Returns a random number in [0..A)

Definition at line 265 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

◆ RandHelper64()

static UE_NODISCARD FORCEINLINE int64 FMath::RandHelper64 ( int64 A)
inlinestatic

Definition at line 272 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

◆ RandPointInBox()

static UE_NODISCARD FVector FMath::RandPointInBox ( const FBox & Box)
static

Returns a random point within the passed in bounding box

◆ RandPointInCircle()

static UE_NODISCARD FVector2D FMath::RandPointInCircle ( float CircleRadius)
static

Returns a random point, uniformly distributed, within the specified radius

◆ RandRange() [1/4]

static UE_NODISCARD FORCEINLINE double FMath::RandRange ( double InMin,
double InMax )
inlinestatic

Definition at line 298 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ RandRange() [2/4]

static UE_NODISCARD FORCEINLINE float FMath::RandRange ( float InMin,
float InMax )
inlinestatic

Util to generate a random number in a range. Overloaded to distinguish from int32 version, where passing a float is typically a mistake.

Definition at line 293 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ RandRange() [3/4]

static UE_NODISCARD FORCEINLINE int32 FMath::RandRange ( int32 Min,
int32 Max )
inlinestatic

Helper function for rand implementations. Returns a random number >= Min and <= Max

Definition at line 280 of file UnrealMathUtility.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RandRange() [4/4]

static UE_NODISCARD FORCEINLINE int64 FMath::RandRange ( int64 Min,
int64 Max )
inlinestatic

Definition at line 286 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ RayPlaneIntersection() [1/2]

template<typename FReal >
static UE_NODISCARD UE::Math::TVector< FReal > FMath::RayPlaneIntersection ( const UE::Math::TVector< FReal > & RayOrigin,
const UE::Math::TVector< FReal > & RayDirection,
const UE::Math::TPlane< FReal > & Plane )
static

Find the intersection of a ray and a plane. The ray has a start point with an infinite length. Assumes that the line and plane do indeed intersect; you must make sure they're not parallel before calling.

Parameters
RayOriginThe start point of the ray
RayDirectionThe direction the ray is pointing (normalized vector)
PlaneThe plane to intersect with
Returns
The point of intersection between the ray and the plane.

◆ RayPlaneIntersection() [2/2]

template<typename T >
UE::Math::TVector< T > FMath::RayPlaneIntersection ( const UE::Math::TVector< T > & RayOrigin,
const UE::Math::TVector< T > & RayDirection,
const UE::Math::TPlane< T > & Plane )
inline

Definition at line 631 of file Plane.h.

◆ RayPlaneIntersectionParam() [1/2]

template<typename FReal >
static UE_NODISCARD FReal FMath::RayPlaneIntersectionParam ( const UE::Math::TVector< FReal > & RayOrigin,
const UE::Math::TVector< FReal > & RayDirection,
const UE::Math::TPlane< FReal > & Plane )
static

Find the intersection of a ray and a plane. The ray has a start point with an infinite length. Assumes that the line and plane do indeed intersect; you must make sure they're not parallel before calling.

Parameters
RayOriginThe start point of the ray
RayDirectionThe direction the ray is pointing (normalized vector)
PlaneThe plane to intersect with
Returns
The distance parameter along ray of the point of intersection between the ray and the plane.

◆ RayPlaneIntersectionParam() [2/2]

template<typename T >
T FMath::RayPlaneIntersectionParam ( const UE::Math::TVector< T > & RayOrigin,
const UE::Math::TVector< T > & RayDirection,
const UE::Math::TPlane< T > & Plane )
inline

Definition at line 642 of file Plane.h.

◆ RESOLVE_FLOAT_AMBIGUITY_2_ARGS()

FMath::RESOLVE_FLOAT_AMBIGUITY_2_ARGS ( FRandRange )

◆ RESOLVE_FLOAT_AMBIGUITY_3_ARGS()

FMath::RESOLVE_FLOAT_AMBIGUITY_3_ARGS ( ClampAngle )

◆ RESOLVE_FLOAT_PREDICATE_AMBIGUITY_2_ARGS() [1/2]

FMath::RESOLVE_FLOAT_PREDICATE_AMBIGUITY_2_ARGS ( IsNearlyEqual )

◆ RESOLVE_FLOAT_PREDICATE_AMBIGUITY_2_ARGS() [2/2]

FMath::RESOLVE_FLOAT_PREDICATE_AMBIGUITY_2_ARGS ( IsNearlyZero )

◆ RESOLVE_FLOAT_PREDICATE_AMBIGUITY_3_ARGS()

FMath::RESOLVE_FLOAT_PREDICATE_AMBIGUITY_3_ARGS ( IsNearlyEqual )

◆ RInterpConstantTo()

static UE_NODISCARD FRotator FMath::RInterpConstantTo ( const FRotator & Current,
const FRotator & Target,
float DeltaTime,
float InterpSpeed )
static

Interpolate rotator from Current to Target with constant step

◆ RInterpTo()

static UE_NODISCARD FRotator FMath::RInterpTo ( const FRotator & Current,
const FRotator & Target,
float DeltaTime,
float InterpSpeed )
static

Interpolate rotator from Current to Target. Scaled by distance to Target, so it has a strong start speed and ease out.

◆ RoundFromZero() [1/2]

static UE_NODISCARD FORCEINLINE double FMath::RoundFromZero ( double F)
inlinestatic

Definition at line 2221 of file UnrealMathUtility.h.

◆ RoundFromZero() [2/2]

static UE_NODISCARD FORCEINLINE float FMath::RoundFromZero ( float F)
inlinestatic

Converts a floating point number to an integer which is further from zero, "larger" in absolute value: 0.1 becomes 1, -0.1 becomes -1

Parameters
FFloating point value to convert
Returns
The rounded integer

Definition at line 2216 of file UnrealMathUtility.h.

◆ RoundHalfFromZero() [1/2]

static UE_NODISCARD double FMath::RoundHalfFromZero ( double F)
static

◆ RoundHalfFromZero() [2/2]

static UE_NODISCARD float FMath::RoundHalfFromZero ( float F)
static

Converts a floating point number to the nearest integer, equidistant ties go to the value which is further from zero: -0.5 becomes -1.0, 0.5 becomes 1.0

Parameters
FFloating point value to convert
Returns
The rounded integer

◆ RoundHalfToEven() [1/2]

static UE_NODISCARD double FMath::RoundHalfToEven ( double F)
static

◆ RoundHalfToEven() [2/2]

static UE_NODISCARD float FMath::RoundHalfToEven ( float F)
static

Converts a floating point number to the nearest integer, equidistant ties go to the value which is closest to an even value: 1.5 becomes 2, 0.5 becomes 0

Parameters
FFloating point value to convert
Returns
The rounded integer

◆ RoundHalfToZero() [1/2]

static UE_NODISCARD double FMath::RoundHalfToZero ( double F)
static

◆ RoundHalfToZero() [2/2]

static UE_NODISCARD float FMath::RoundHalfToZero ( float F)
static

Converts a floating point number to the nearest integer, equidistant ties go to the value which is closer to zero: -0.5 becomes 0, 0.5 becomes 0

Parameters
FFloating point value to convert
Returns
The rounded integer

◆ RoundToNegativeInfinity() [1/2]

static UE_NODISCARD FORCEINLINE double FMath::RoundToNegativeInfinity ( double F)
inlinestatic

Definition at line 2251 of file UnrealMathUtility.h.

◆ RoundToNegativeInfinity() [2/2]

static UE_NODISCARD FORCEINLINE float FMath::RoundToNegativeInfinity ( float F)
inlinestatic

Converts a floating point number to an integer which is more negative: 0.1 becomes 0, -0.1 becomes -1

Parameters
FFloating point value to convert
Returns
The rounded integer

Definition at line 2246 of file UnrealMathUtility.h.

◆ RoundToPositiveInfinity() [1/2]

static UE_NODISCARD FORCEINLINE double FMath::RoundToPositiveInfinity ( double F)
inlinestatic

Definition at line 2266 of file UnrealMathUtility.h.

◆ RoundToPositiveInfinity() [2/2]

static UE_NODISCARD FORCEINLINE float FMath::RoundToPositiveInfinity ( float F)
inlinestatic

Converts a floating point number to an integer which is more positive: 0.1 becomes 1, -0.1 becomes 0

Parameters
FFloating point value to convert
Returns
The rounded integer

Definition at line 2261 of file UnrealMathUtility.h.

◆ RoundToZero() [1/2]

static UE_NODISCARD FORCEINLINE double FMath::RoundToZero ( double F)
inlinestatic

Definition at line 2236 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

◆ RoundToZero() [2/2]

static UE_NODISCARD FORCEINLINE float FMath::RoundToZero ( float F)
inlinestatic

Converts a floating point number to an integer which is closer to zero, "smaller" in absolute value: 0.1 becomes 0, -0.1 becomes 0

Parameters
FFloating point value to convert
Returns
The rounded integer

Definition at line 2231 of file UnrealMathUtility.h.

◆ SegmentDistToSegment()

static void FMath::SegmentDistToSegment ( FVector A1,
FVector B1,
FVector A2,
FVector B2,
FVector & OutP1,
FVector & OutP2 )
static

Find closest points between 2 segments.

If either segment may have a length of 0, use SegmentDistToSegmentSafe instance.

Parameters
(A1,B1)defines the first segment.
(A2,B2)defines the second segment.
OutP1Closest point on segment 1 to segment 2.
OutP2Closest point on segment 2 to segment 1.

◆ SegmentDistToSegmentSafe()

static void FMath::SegmentDistToSegmentSafe ( FVector A1,
FVector B1,
FVector A2,
FVector B2,
FVector & OutP1,
FVector & OutP2 )
static

Find closest points between 2 segments.

This is the safe version, and will check both segments' lengths. Use this if either (or both) of the segments lengths may be 0.

Parameters
(A1,B1)defines the first segment.
(A2,B2)defines the second segment.
OutP1Closest point on segment 1 to segment 2.
OutP2Closest point on segment 2 to segment 1.

◆ SegmentIntersection2D()

static bool FMath::SegmentIntersection2D ( const FVector & SegmentStartA,
const FVector & SegmentEndA,
const FVector & SegmentStartB,
const FVector & SegmentEndB,
FVector & out_IntersectionPoint )
static

Returns true if there is an intersection between the segment specified by SegmentStartA and SegmentEndA, and the segment specified by SegmentStartB and SegmentEndB, in 2D space. If there is an intersection, the point is placed in out_IntersectionPoint

Parameters
SegmentStartA- start point of first segment
SegmentEndA- end point of first segment
SegmentStartB- start point of second segment
SegmentEndB- end point of second segment
out_IntersectionPoint- out var for the intersection point (if any)
Returns
true if intersection occurred

◆ SegmentPlaneIntersection()

static bool FMath::SegmentPlaneIntersection ( const FVector & StartPoint,
const FVector & EndPoint,
const FPlane & Plane,
FVector & out_IntersectionPoint )
static

Returns true if there is an intersection between the segment specified by StartPoint and Endpoint, and the plane on which polygon Plane lies. If there is an intersection, the point is placed in out_IntersectionPoint

Parameters
StartPoint- start point of segment
EndPoint- end point of segment
Plane- plane to intersect with
out_IntersectionPoint- out var for the point on the segment that intersects the mesh (if any)
Returns
true if intersection occurred

◆ SegmentTriangleIntersection()

static bool FMath::SegmentTriangleIntersection ( const FVector & StartPoint,
const FVector & EndPoint,
const FVector & A,
const FVector & B,
const FVector & C,
FVector & OutIntersectPoint,
FVector & OutTriangleNormal )
static

Returns true if there is an intersection between the segment specified by StartPoint and Endpoint, and the Triangle defined by A, B and C. If there is an intersection, the point is placed in out_IntersectionPoint

Parameters
StartPoint- start point of segment
EndPoint- end point of segment
A,B,C- points defining the triangle
OutIntersectPoint- out var for the point on the segment that intersects the triangle (if any)
OutTriangleNormal- out var for the triangle normal
Returns
true if intersection occurred

◆ SetBoolInBitField()

static constexpr void FMath::SetBoolInBitField ( uint8 * Ptr,
uint32 Index,
bool bSet )
inlinestaticconstexpr

Set a bit in memory created from bitflags (uint32 Value:1), used for EngineShowFlags, TestBitFieldFunctions() tests the implementation

Definition at line 2395 of file UnrealMathUtility.h.

◆ SinCos() [1/3]

static FORCEINLINE void FMath::SinCos ( double * ScalarSin,
double * ScalarCos,
double Value )
inlinestatic

Definition at line 743 of file UnrealMathUtility.h.

◆ SinCos() [2/3]

template<typename T UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static constexpr FORCEINLINE void FMath::SinCos ( std::decay_t< T > * ScalarSin,
std::decay_t< T > * ScalarCos,
T Value )
inlinestaticconstexpr

Computes the sine and cosine of a scalar value.

Parameters
ScalarSinPointer to where the Sin result should be stored
ScalarCosPointer to where the Cos result should be stored
Valueinput angles

Definition at line 702 of file UnrealMathUtility.h.

◆ SinCos() [3/3]

template<typename T , typename U UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static FORCEINLINE void FMath::SinCos ( T * ScalarSin,
T * ScalarCos,
U Value )
inlinestatic

Definition at line 757 of file UnrealMathUtility.h.

◆ SmoothStep()

template<typename T >
static UE_NODISCARD constexpr T FMath::SmoothStep ( T A,
T B,
T X )
inlinestaticconstexpr

Returns a smooth Hermite interpolation between 0 and 1 for the value X (where X ranges between A and B) Clamped to 0 for X <= A and 1 for X >= B.

Parameters
AMinimum value of X
BMaximum value of X
XParameter
Returns
Smoothed value between 0 and 1

Definition at line 2365 of file UnrealMathUtility.h.

◆ SphereAABBIntersection() [1/4]

template<typename FReal >
bool FMath::SphereAABBIntersection ( const UE::Math::TSphere< FReal > & Sphere,
const UE::Math::TBox< FReal > & AABB )
inline

Converts a sphere into a point plus radius squared for the test above

Definition at line 1049 of file Box.h.

◆ SphereAABBIntersection() [2/4]

template<typename FReal >
static UE_NODISCARD bool FMath::SphereAABBIntersection ( const UE::Math::TSphere< FReal > & Sphere,
const UE::Math::TBox< FReal > & AABB )
static

Converts a sphere into a point plus radius squared for the test above

◆ SphereAABBIntersection() [3/4]

template<typename FReal >
bool FMath::SphereAABBIntersection ( const UE::Math::TVector< FReal > & SphereCenter,
const FReal RadiusSquared,
const UE::Math::TBox< FReal > & AABB )
inline

Performs a sphere vs box intersection test using Arvo's algorithm:

for each i in (x, y, z) if (SphereCenter(i) < BoxMin(i)) d2 += (SphereCenter(i) - BoxMin(i)) ^ 2 else if (SphereCenter(i) > BoxMax(i)) d2 += (SphereCenter(i) - BoxMax(i)) ^ 2

Parameters
SphereCenterthe center of the sphere being tested against the AABB
RadiusSquaredthe size of the sphere being tested
AABBthe box being tested against
Returns
Whether the sphere/box intersect or not.

Definition at line 1011 of file Box.h.

◆ SphereAABBIntersection() [4/4]

template<typename FReal >
static UE_NODISCARD bool FMath::SphereAABBIntersection ( const UE::Math::TVector< FReal > & SphereCenter,
const FReal RadiusSquared,
const UE::Math::TBox< FReal > & AABB )
static

Performs a sphere vs box intersection test using Arvo's algorithm:

for each i in (x, y, z) if (SphereCenter(i) < BoxMin(i)) d2 += (SphereCenter(i) - BoxMin(i)) ^ 2 else if (SphereCenter(i) > BoxMax(i)) d2 += (SphereCenter(i) - BoxMax(i)) ^ 2

Parameters
SphereCenterthe center of the sphere being tested against the AABB
RadiusSquaredthe size of the sphere being tested
AABBthe box being tested against
Returns
Whether the sphere/box intersect or not.

◆ SphereConeIntersection()

static UE_NODISCARD bool FMath::SphereConeIntersection ( const FVector & SphereCenter,
float SphereRadius,
const FVector & ConeAxis,
float ConeAngleSin,
float ConeAngleCos )
static

Assumes the cone tip is at 0,0,0 (means the SphereCenter is relative to the cone tip)

Returns
true: cone and sphere do intersect, false otherwise

◆ SphereDistToLine()

static void FMath::SphereDistToLine ( FVector SphereOrigin,
float SphereRadius,
FVector LineOrigin,
FVector LineDir,
FVector & OutClosestPoint )
static

Find closest point on a Sphere to a Line. When line intersects Sphere, then closest point to LineOrigin is returned.

Parameters
SphereOriginOrigin of Sphere
SphereRadiusRadius of Sphere
LineOriginOrigin of line
LineDirDirection of line. Needs to be normalized!!
OutClosestPointClosest point on sphere to given line.

◆ SpringDamper()

template<class T >
static void FMath::SpringDamper ( T & InOutValue,
T & InOutValueRate,
const T & InTargetValue,
const T & InTargetValueRate,
const float InDeltaTime,
const float InUndampedFrequency,
const float InDampingRatio )
inlinestatic

Smooths a value using a spring damper towards a target.

The implementation uses approximations for Exp/Sin/Cos. These are accurate for all sensible values of InUndampedFrequency and DampingRatio so long as InDeltaTime < 1 / InUndampedFrequency (approximately), but are generally well behaved even for larger timesteps etc.

Parameters
InOutValueThe value to be smoothed
InOutValueRateThe rate of change of the value
InTargetValueThe target to smooth towards
InTargetValueRateThe target rate of change smooth towards. Note that if this is discontinuous, then the output will have discontinuous velocity too.
InDeltaTimeTime interval
InUndampedFrequencyOscillation frequency when there is no damping. Proportional to the square root of the spring stiffness.
InDampingRatio1 is critical damping. <1 results in under-damped motion (i.e. with overshoot), and >1 results in over-damped motion.

Definition at line 1695 of file UnrealMathUtility.h.

◆ SpringDamperSmoothing()

template<class T >
static void FMath::SpringDamperSmoothing ( T & InOutValue,
T & InOutValueRate,
const T & InTargetValue,
const T & InTargetValueRate,
const float InDeltaTime,
const float InSmoothingTime,
const float InDampingRatio )
inlinestatic

Smooths a value using a spring damper towards a target.

The implementation uses approximations for Exp/Sin/Cos. These are accurate for all sensible values of DampingRatio and InSmoothingTime so long as InDeltaTime < 0.5 * InSmoothingTime, but are generally well behaved even for larger timesteps etc.

Parameters
InOutValueThe value to be smoothed
InOutValueRateThe rate of change of the value
InTargetValueThe target to smooth towards
InTargetValueRateThe target rate of change smooth towards. Note that if this is discontinuous, then the output will have discontinuous velocity too.
InDeltaTimeTime interval
InSmoothingTimeTimescale over which to smooth. Larger values result in more smoothed behaviour. Can be zero.
InDampingRatio1 is critical damping. <1 results in under-damped motion (i.e. with overshoot), and >1 results in over-damped motion.

Definition at line 1794 of file UnrealMathUtility.h.

◆ Square()

template<class T >
static UE_NODISCARD constexpr FORCEINLINE T FMath::Square ( const T A)
inlinestaticconstexpr

Multiples value by itself

Definition at line 574 of file UnrealMathUtility.h.

◆ TIsNearlyEqualByULP()

template<typename FloatType , typename IntegralType , IntegralType SignedBit>
static bool FMath::TIsNearlyEqualByULP ( FloatType A,
FloatType B,
int32 MaxUlps )
inlinestaticprivate

Definition at line 418 of file UnrealMathUtility.h.

◆ TruncateToHalfIfClose() [1/2]

static UE_NODISCARD double FMath::TruncateToHalfIfClose ( double F,
double Tolerance = UE_SMALL_NUMBER )
static

◆ TruncateToHalfIfClose() [2/2]

static UE_NODISCARD float FMath::TruncateToHalfIfClose ( float F,
float Tolerance = UE_SMALL_NUMBER )
static

Truncates a floating point number to half if closer than the given tolerance.

Parameters
FFloating point number to truncate
ToleranceMaximum allowed difference to 0.5 in order to truncate
Returns
The truncated value

◆ UnwindDegrees()

template<typename T UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr T FMath::UnwindDegrees ( T A)
inlinestaticconstexpr

Utility to ensure angle is between +/- 180 degrees by unwinding.

Definition at line 931 of file UnrealMathUtility.h.

◆ UnwindRadians()

template<typename T UE_CONSTRAINTS_BEGIN UE_CONSTRAINTS_END>
static UE_NODISCARD constexpr T FMath::UnwindRadians ( T A)
inlinestaticconstexpr

Given a heading which may be outside the +/- PI range, 'unwind' it back into that range.

Definition at line 909 of file UnrealMathUtility.h.

◆ Vector2DInterpConstantTo()

static UE_NODISCARD FVector2D FMath::Vector2DInterpConstantTo ( const FVector2D & Current,
const FVector2D & Target,
float DeltaTime,
float InterpSpeed )
static

Interpolate vector2D from Current to Target with constant step

◆ Vector2DInterpTo()

static UE_NODISCARD FVector2D FMath::Vector2DInterpTo ( const FVector2D & Current,
const FVector2D & Target,
float DeltaTime,
float InterpSpeed )
static

Interpolate vector2D from Current to Target. Scaled by distance to Target, so it has a strong start speed and ease out.

◆ VInterpConstantTo()

static UE_NODISCARD FVector FMath::VInterpConstantTo ( const FVector & Current,
const FVector & Target,
float DeltaTime,
float InterpSpeed )
static

Interpolate vector from Current to Target with constant step

◆ VInterpNormalRotationTo()

static UE_NODISCARD FVector FMath::VInterpNormalRotationTo ( const FVector & Current,
const FVector & Target,
float DeltaTime,
float RotationSpeedDegrees )
static

Interpolate a normal vector Current to Target, by interpolating the angle between those vectors with constant step.

◆ VInterpTo()

static UE_NODISCARD FVector FMath::VInterpTo ( const FVector & Current,
const FVector & Target,
float DeltaTime,
float InterpSpeed )
static

Interpolate vector from Current to Target. Scaled by distance to Target, so it has a strong start speed and ease out.

◆ VRand()

FVector FMath::VRand ( )
inlinestatic

Return a uniformly distributed random unit length vector = point on the unit sphere surface.

Definition at line 2621 of file Vector.h.

◆ VRandCone() [1/2]

static UE_NODISCARD FVector FMath::VRandCone ( FVector const & Dir,
float ConeHalfAngleRad )
static

Returns a random unit vector, uniformly distributed, within the specified cone ConeHalfAngleRad is the half-angle of cone, in radians. Returns a normalized vector.

◆ VRandCone() [2/2]

static UE_NODISCARD FVector FMath::VRandCone ( FVector const & Dir,
float HorizontalConeHalfAngleRad,
float VerticalConeHalfAngleRad )
static

This is a version of VRandCone that handles "squished" cones, i.e. with different angle limits in the Y and Z axes. Assumes world Y and Z, although this could be extended to handle arbitrary rotations.

◆ WeightedMovingAverage()

template<typename T >
static UE_NODISCARD T FMath::WeightedMovingAverage ( T CurrentSample,
T PreviousSample,
T Weight )
inlinestatic

Calculates the new value in a weighted moving average series using the previous value and the weight

Parameters
CurrentSample- The value to blend with the previous sample to get a new weighted value
PreviousSample- The last value from the series
Weight- The weight to blend with
Returns
the next value in the series

Definition at line 2497 of file UnrealMathUtility.h.

◆ WindRelativeAnglesDegrees() [1/2]

static void FMath::WindRelativeAnglesDegrees ( double InAngle0,
double & InOutAngle1 )
static

◆ WindRelativeAnglesDegrees() [2/2]

static void FMath::WindRelativeAnglesDegrees ( float InAngle0,
float & InOutAngle1 )
static

Given two angles in degrees, 'wind' the rotation in Angle1 so that it avoids >180 degree flips. Good for winding rotations previously expressed as quaternions into a euler-angle representation.

Parameters
InAngle0The first angle that we wind relative to.
InOutAngle1The second angle that we may wind relative to the first.

◆ Wrap()

template<class T >
static UE_NODISCARD constexpr FORCEINLINE T FMath::Wrap ( const T X,
const T Min,
const T Max )
inlinestaticconstexpr

Wraps X to be between Min and Max, inclusive. When X can wrap to both Min and Max, it will wrap to Min if it lies below the range and wrap to Max if it is above the range.

Definition at line 605 of file UnrealMathUtility.h.

Member Data Documentation

◆ BitFlag

const uint32 FMath::BitFlag[32]
static

32 bit values where BitFlag[x] == (1<<x)

Definition at line 2352 of file UnrealMathUtility.h.


The documentation for this struct was generated from the following files: