UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FMath Struct Reference

#include <UnrealMathUtility.h>

+ Inheritance 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< T > ClosestPointOnLine (const UE::Math::TVector< T > &LineStart, const UE::Math::TVector< T > &LineEnd, const UE::Math::TVector< T > &Point)
 
template<typename T >
UE::Math::TVector< T > ClosestPointOnSegment (const UE::Math::TVector< T > &Point, const UE::Math::TVector< T > &StartPoint, const UE::Math::TVector< T > &EndPoint)
 
template<typename T >
UE::Math::TVector2< T > ClosestPointOnSegment2D (const UE::Math::TVector2< T > &Point, const UE::Math::TVector2< T > &StartPoint, const UE::Math::TVector2< T > &EndPoint)
 
template<typename T >
void SegmentDistToSegmentSafe (UE::Math::TVector< T > A1, UE::Math::TVector< T > B1, UE::Math::TVector< T > A2, UE::Math::TVector< T > B2, UE::Math::TVector< T > &OutP1, UE::Math::TVector< T > &OutP2)
 
template<typename T >
UE::Math::TVector< T > RayPlaneIntersection (const UE::Math::TVector< T > &RayOrigin, const UE::Math::TVector< T > &RayDirection, const UE::Math::TPlane< T > &Plane)
 
template<typename 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< T > LinePlaneIntersection (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 T , typename U >
UE_FORCEINLINE_HINT UE::Math::TRotator< T > LerpRange (const UE::Math::TRotator< T > &A, const UE::Math::TRotator< T > &B, U Alpha)
 
template<typename T >
UE::Math::TVector< T > 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)
 
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)
 

Static Public Member Functions

static UE_FORCEINLINE_HINT int32 RandHelper (int32 A)
 
static UE_FORCEINLINE_HINT int64 RandHelper64 (int64 A)
 
static int32 RandRange (int32 Min, int32 Max)
 
static int64 RandRange (int64 Min, int64 Max)
 
static UE_FORCEINLINE_HINT float RandRange (float InMin, float InMax)
 
static UE_FORCEINLINE_HINT double RandRange (double InMin, double InMax)
 
static UE_FORCEINLINE_HINT float FRandRange (float InMin, float InMax)
 
static UE_FORCEINLINE_HINT double FRandRange (double InMin, double InMax)
 
static UE_FORCEINLINE_HINT bool RandBool ()
 
static FVector VRand ()
 
static CORE_API FVector VRandCone (FVector const &Dir, float ConeHalfAngleRad)
 
static CORE_API FVector VRandCone (FVector const &Dir, float HorizontalConeHalfAngleRad, float VerticalConeHalfAngleRad)
 
static CORE_API FVector2D RandPointInCircle (float CircleRadius)
 
static CORE_API FVector RandPointInBox (const FBox &Box)
 
static CORE_API FVector GetReflectionVector (const FVector &Direction, const FVector &SurfaceNormal)
 
template<class T , class U >
static constexpr UE_FORCEINLINE_HINT bool IsWithin (const T &TestValue, const U &MinValue, const U &MaxValue)
 
template<class T , class U >
static constexpr UE_FORCEINLINE_HINT bool IsWithinInclusive (const T &TestValue, const U &MinValue, const U &MaxValue)
 
static UE_FORCEINLINE_HINT bool IsNearlyEqual (float A, float B, float ErrorTolerance=UE_SMALL_NUMBER)
 
static UE_FORCEINLINE_HINT bool IsNearlyEqual (double A, double B, double ErrorTolerance=UE_DOUBLE_SMALL_NUMBER)
 
static UE_FORCEINLINE_HINT bool IsNearlyZero (float Value, float ErrorTolerance=UE_SMALL_NUMBER)
 
static UE_FORCEINLINE_HINT bool IsNearlyZero (double Value, double ErrorTolerance=UE_DOUBLE_SMALL_NUMBER)
 
static UE_FORCEINLINE_HINT bool IsNearlyEqualByULP (float A, float B, int32 MaxUlps=4)
 
static UE_FORCEINLINE_HINT bool IsNearlyEqualByULP (double A, double B, int32 MaxUlps=4)
 
template<typename T >
static constexpr UE_FORCEINLINE_HINT bool IsPowerOfTwo (T Value)
 
static UE_FORCEINLINE_HINT float Floor (float F)
 
static UE_FORCEINLINE_HINT double Floor (double F)
 
template<UE::CIntegral IntegralType>
static constexpr UE_FORCEINLINE_HINT IntegralType Floor (IntegralType I)
 
template<class T >
static constexpr UE_FORCEINLINE_HINTMax3 (const T A, const T B, const T C)
 
template<class T >
static constexpr UE_FORCEINLINE_HINTMin3 (const T A, const T B, const T C)
 
template<class T >
static constexpr UE_FORCEINLINE_HINT int32 Max3Index (const T A, const T B, const T C)
 
template<class T >
static constexpr UE_FORCEINLINE_HINT int32 Min3Index (const T A, const T B, const T C)
 
template<class T >
static constexpr UE_FORCEINLINE_HINTSquare (const T A)
 
template<class T >
static constexpr UE_FORCEINLINE_HINTCube (const T A)
 
template<class T >
static constexpr UE_FORCEINLINE_HINTClamp (const T X, const T MinValue, const T MaxValue)
 
static constexpr UE_FORCEINLINE_HINT float Clamp (const float X, const float Min, const float Max)
 
static constexpr UE_FORCEINLINE_HINT double Clamp (const double X, const double Min, const double Max)
 
static constexpr UE_FORCEINLINE_HINT int64 Clamp (const int64 X, const int32 Min, const int32 Max)
 
template<UE::CFloatingPoint T>
static constexpr UE_FORCEINLINE_HINTWrap (const T X, const T Min, const T Max)
 
template<UE::CIntegral T>
static constexprWrapExclusive (const T X, const T Min, const T Max)
 
template<typename ValueType , typename BaseType >
static constexpr auto Modulo (ValueType Value, BaseType Base)
 
template<class T >
static constexpr UE_FORCEINLINE_HINTGridSnap (T Location, T Grid)
 
template<class T >
static constexpr UE_FORCEINLINE_HINTDivideAndRoundUp (T Dividend, T Divisor)
 
template<class T >
static constexpr UE_FORCEINLINE_HINTDivideAndRoundDown (T Dividend, T Divisor)
 
template<class T >
static constexprDivideAndRoundNearest (T Dividend, T Divisor)
 
static float Log2 (float Value)
 
static double Log2 (double Value)
 
template<UE::CFloatingPoint T>
static constexpr void SinCos (std::decay_t< T > *ScalarSin, std::decay_t< T > *ScalarCos, T Value)
 
static void SinCos (double *ScalarSin, double *ScalarCos, double Value)
 
template<typename T , typename U >
static UE_FORCEINLINE_HINT void SinCos (T *ScalarSin, T *ScalarCos, U Value)
 
static float FastAsin (float Value)
 
static UE_FORCEINLINE_HINT double FastAsin (double Value)
 
template<class T >
static constexpr UE_FORCEINLINE_HINT auto RadiansToDegrees (T const &RadVal) -> decltype(RadVal *(180.f/UE_PI))
 
static constexpr UE_FORCEINLINE_HINT float RadiansToDegrees (float const &RadVal)
 
static constexpr UE_FORCEINLINE_HINT double RadiansToDegrees (double const &RadVal)
 
template<class T >
static constexpr UE_FORCEINLINE_HINT auto DegreesToRadians (T const &DegVal) -> decltype(DegVal *(UE_PI/180.f))
 
static constexpr UE_FORCEINLINE_HINT float DegreesToRadians (float const &DegVal)
 
static constexpr UE_FORCEINLINE_HINT double DegreesToRadians (double const &DegVal)
 
template<typename T >
staticClampAngle (T AngleDegrees, T MinAngleDegrees, T MaxAngleDegrees)
 
template<typename T , typename T2 >
static constexpr auto FindDeltaAngleDegrees (T A1, T2 A2) -> decltype(A1 - A2)
 
template<typename T , typename T2 >
static constexpr auto FindDeltaAngleRadians (T A1, T2 A2) -> decltype(A1 - A2)
 
template<UE::CFloatingPoint T>
static constexprUnwindRadians (T A)
 
template<UE::CFloatingPoint T>
static constexprUnwindDegrees (T A)
 
static CORE_API void WindRelativeAnglesDegrees (float InAngle0, float &InOutAngle1)
 
static CORE_API void WindRelativeAnglesDegrees (double InAngle0, double &InOutAngle1)
 
static CORE_API float FixedTurn (float InCurrent, float InDesired, float InDeltaRate)
 
template<typename T >
static void CartesianToPolar (const T X, const T Y, T &OutRad, T &OutAng)
 
template<typename T >
static UE_FORCEINLINE_HINT void CartesianToPolar (const UE::Math::TVector2< T > InCart, UE::Math::TVector2< T > &OutPolar)
 
template<typename T >
static void PolarToCartesian (const T Rad, const T Ang, T &OutX, T &OutY)
 
template<typename T >
static UE_FORCEINLINE_HINT void PolarToCartesian (const UE::Math::TVector2< T > InPolar, UE::Math::TVector2< T > &OutCart)
 
static CORE_API bool GetDotDistance (FVector2D &OutDotDist, const FVector &Direction, const FVector &AxisX, const FVector &AxisY, const FVector &AxisZ)
 
static CORE_API FVector2D GetAzimuthAndElevation (const FVector &Direction, const FVector &AxisX, const FVector &AxisY, const FVector &AxisZ)
 
template<UE::CFloatingPoint T, typename T2 >
static constexpr auto GetRangePct (T MinValue, T MaxValue, T2 Value)
 
template<UE::CFloatingPoint T, typename T2 >
static auto GetRangePct (UE::Math::TVector2< T > const &Range, T2 Value)
 
template<UE::CFloatingPoint T, typename T2 >
static auto GetRangeValue (UE::Math::TVector2< T > const &Range, T2 Pct)
 
template<typename T , typename T2 >
static auto GetMappedRangeValueClamped (const UE::Math::TVector2< T > &InputRange, const UE::Math::TVector2< T > &OutputRange, const T2 Value)
 
template<typename T , typename T2 >
static UE_FORCEINLINE_HINT auto GetMappedRangeValueUnclamped (const UE::Math::TVector2< T > &InputRange, const UE::Math::TVector2< T > &OutputRange, const T2 Value)
 
template<class T >
static UE_FORCEINLINE_HINT double GetRangePct (TRange< T > const &Range, T Value)
 
template<class T >
static UE_FORCEINLINE_HINTGetRangeValue (TRange< T > const &Range, T Pct)
 
template<class T >
staticGetMappedRangeValueClamped (const TRange< T > &InputRange, const TRange< T > &OutputRange, const T Value)
 
template<typename T , typename U >
static constexpr UE_FORCEINLINE_HINTLerp (const T &A, const T &B, const U &Alpha)
 
template<typename T , typename U >
static UE_FORCEINLINE_HINTLerp (const T &A, const T &B, const U &Alpha)
 
template<typename T1 , typename T2 , typename T3 >
static auto Lerp (const T1 &A, const T2 &B, const T3 &Alpha) -> decltype(A *B)
 
template<class T >
static constexpr UE_FORCEINLINE_HINTLerpStable (const T &A, const T &B, double Alpha)
 
template<class T >
static constexpr UE_FORCEINLINE_HINTLerpStable (const T &A, const T &B, float Alpha)
 
template<typename T1 , typename T2 , typename T3 >
static auto LerpStable (const T1 &A, const T2 &B, const T3 &Alpha) -> decltype(A *B)
 
template<typename T , typename U >
static constexprBiLerp (const T &P00, const T &P10, const T &P01, const T &P11, const U &FracX, const U &FracY)
 
template<typename T , typename U >
static UE_FORCEINLINE_HINTBiLerp (const T &P00, const T &P10, const T &P01, const T &P11, const U &FracX, const U &FracY)
 
template<typename T , typename U >
static constexprCubicInterp (const T &P0, const T &T0, const T &P1, const T &T1, const U &A)
 
template<typename T , typename U >
static UE_FORCEINLINE_HINTCubicInterp (const T &P0, const T &T0, const T &P1, const T &T1, const U &A)
 
template<typename T , UE::CFloatingPoint U>
static constexprCubicInterpDerivative (const T &P0, const T &T0, const T &P1, const T &T1, const U &A)
 
template<typename T , UE::CFloatingPoint U>
static constexprCubicInterpSecondDerivative (const T &P0, const T &T0, const T &P1, const T &T1, const U &A)
 
template<class T >
staticInterpEaseIn (const T &A, const T &B, float Alpha, float Exp)
 
template<class T >
staticInterpEaseOut (const T &A, const T &B, float Alpha, float Exp)
 
template<class T >
staticInterpEaseInOut (const T &A, const T &B, float Alpha, float Exp)
 
template<class T >
static constexprInterpStep (const T &A, const T &B, float Alpha, int32 Steps)
 
template<class T >
staticInterpSinIn (const T &A, const T &B, float Alpha)
 
template<class T >
staticInterpSinOut (const T &A, const T &B, float Alpha)
 
template<class T >
staticInterpSinInOut (const T &A, const T &B, float Alpha)
 
template<class T >
staticInterpExpoIn (const T &A, const T &B, float Alpha)
 
template<class T >
staticInterpExpoOut (const T &A, const T &B, float Alpha)
 
template<class T >
staticInterpExpoInOut (const T &A, const T &B, float Alpha)
 
template<class T >
staticInterpCircularIn (const T &A, const T &B, float Alpha)
 
template<class T >
staticInterpCircularOut (const T &A, const T &B, float Alpha)
 
template<class T >
staticInterpCircularInOut (const T &A, const T &B, float Alpha)
 
template<typename T , typename U >
static UE::Math::TRotator< T > LerpRange (const UE::Math::TRotator< T > &A, const UE::Math::TRotator< T > &B, U Alpha)
 
template<class U >
static constexprCubicCRSplineInterp (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 constexprCubicCRSplineInterpSafe (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 CORE_API FVector VInterpNormalRotationTo (const FVector &Current, const FVector &Target, float DeltaTime, float RotationSpeedDegrees)
 
static CORE_API FVector VInterpConstantTo (const FVector &Current, const FVector &Target, float DeltaTime, float InterpSpeed)
 
static CORE_API FVector VInterpTo (const FVector &Current, const FVector &Target, float DeltaTime, float InterpSpeed)
 
static CORE_API FVector2D Vector2DInterpConstantTo (const FVector2D &Current, const FVector2D &Target, float DeltaTime, float InterpSpeed)
 
template<typename T >
static CORE_API UE::Math::TVector2< T > Vector2DInterpTo (const UE::Math::TVector2< T > &Current, const UE::Math::TVector2< T > &Target, float DeltaTime, float InterpSpeed)
 
static CORE_API FRotator RInterpConstantTo (const FRotator &Current, const FRotator &Target, float DeltaTime, float InterpSpeed)
 
static CORE_API 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 auto FInterpConstantTo (T1 Current, T2 Target, T3 DeltaTime, T4 InterpSpeed)
 
template<typename T1 , typename T2 = T1, typename T3 = T2, typename T4 = T3>
static auto FInterpTo (T1 Current, T2 Target, T3 DeltaTime, T4 InterpSpeed)
 
static CORE_API FLinearColor CInterpTo (const FLinearColor &Current, const FLinearColor &Target, float DeltaTime, float InterpSpeed)
 
template<class T >
static CORE_API UE::Math::TQuat< T > QInterpConstantTo (const UE::Math::TQuat< T > &Current, const UE::Math::TQuat< T > &Target, float DeltaTime, float InterpSpeed)
 
template<class T >
static CORE_API UE::Math::TQuat< T > QInterpTo (const UE::Math::TQuat< T > &Current, const UE::Math::TQuat< T > &Target, float DeltaTime, float InterpSpeed)
 
template<class T >
static constexprInvExpApprox (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 float MakePulsatingValue (const double InCurrentTime, const float InPulsesPerSecond, const float InPhase=0.0f)
 
template<typename FReal >
static 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 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::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::Math::TVector< FReal > LinePlaneIntersection (const UE::Math::TVector< FReal > &Point1, const UE::Math::TVector< FReal > &Point2, const UE::Math::TPlane< FReal > &Plane)
 
static CORE_API uint32 ComputeProjectedSphereScissorRect (FIntRect &InOutScissorRect, FVector SphereOrigin, float Radius, FVector ViewOrigin, const FMatrix &ViewMatrix, const FMatrix &ProjMatrix)
 
template<typename FReal >
static UE::Math::TSphere< FReal > ComputeBoundingSphereForCone (UE::Math::TVector< FReal > const &ConeOrigin, UE::Math::TVector< FReal > const &ConeDirection, FReal ConeRadius, FReal CosConeAngle, FReal SinConeAngle)
 
static CORE_API bool PlaneAABBIntersection (const FPlane &P, const FBox &AABB)
 
static CORE_API int32 PlaneAABBRelativePosition (const FPlane &P, const FBox &AABB)
 
template<typename FReal >
static bool SphereAABBIntersection (const UE::Math::TVector< FReal > &SphereCenter, const FReal RadiusSquared, const UE::Math::TBox< FReal > &AABB)
 
template<typename FReal >
static bool SphereAABBIntersection (const UE::Math::TSphere< FReal > &Sphere, const UE::Math::TBox< FReal > &AABB)
 
template<typename FReal >
static bool PointBoxIntersection (const UE::Math::TVector< FReal > &Point, const UE::Math::TBox< FReal > &Box)
 
template<typename FReal >
static 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 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)
 
template<typename FReal >
static bool LineBoxIntersection2D (const UE::Math::TBox2< FReal > &Box, const UE::Math::TVector2< FReal > &Start, const UE::Math::TVector2< FReal > &End)
 
static CORE_API bool LineExtentBoxIntersection (const FBox &inBox, const FVector &Start, const FVector &End, const FVector &Extent, FVector &HitLocation, FVector &HitNormal, float &HitTime)
 
template<typename FReal >
static 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 CORE_API bool SphereConeIntersection (const FVector &SphereCenter, float SphereRadius, const FVector &ConeAxis, float ConeAngleSin, float ConeAngleCos)
 
template<typename T >
static CORE_API UE::Math::TVector< T > ClosestPointOnLine (const UE::Math::TVector< T > &LineStart, const UE::Math::TVector< T > &LineEnd, const UE::Math::TVector< T > &Point)
 
static CORE_API FVector ClosestPointOnInfiniteLine (const FVector &LineStart, const FVector &LineEnd, const FVector &Point)
 
template<typename FReal >
static 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 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 CORE_API float PointDistToLine (const FVector &Point, const FVector &Direction, const FVector &Origin, FVector &OutClosestPoint)
 
static CORE_API float PointDistToLine (const FVector &Point, const FVector &Direction, const FVector &Origin)
 
template<typename T >
static CORE_API UE::Math::TVector< T > ClosestPointOnSegment (const UE::Math::TVector< T > &Point, const UE::Math::TVector< T > &StartPoint, const UE::Math::TVector< T > &EndPoint)
 
template<typename T >
static CORE_API UE::Math::TVector2< T > ClosestPointOnSegment2D (const UE::Math::TVector2< T > &Point, const UE::Math::TVector2< T > &StartPoint, const UE::Math::TVector2< T > &EndPoint)
 
static CORE_API float PointDistToSegment (const FVector &Point, const FVector &StartPoint, const FVector &EndPoint)
 
static CORE_API float PointDistToSegmentSquared (const FVector &Point, const FVector &StartPoint, const FVector &EndPoint)
 
static CORE_API void SegmentDistToSegment (FVector A1, FVector B1, FVector A2, FVector B2, FVector &OutP1, FVector &OutP2)
 
template<typename T >
static CORE_API void SegmentDistToSegmentSafe (UE::Math::TVector< T > A1, UE::Math::TVector< T > B1, UE::Math::TVector< T > A2, UE::Math::TVector< T > B2, UE::Math::TVector< T > &OutP1, UE::Math::TVector< T > &OutP2)
 
static CORE_API float GetTForSegmentPlaneIntersect (const FVector &StartPoint, const FVector &EndPoint, const FPlane &Plane)
 
static CORE_API bool SegmentPlaneIntersection (const FVector &StartPoint, const FVector &EndPoint, const FPlane &Plane, FVector &out_IntersectionPoint)
 
static CORE_API bool SegmentTriangleIntersection (const FVector &StartPoint, const FVector &EndPoint, const FVector &A, const FVector &B, const FVector &C, FVector &OutIntersectPoint, FVector &OutTriangleNormal)
 
static CORE_API bool SegmentIntersection2D (const FVector &SegmentStartA, const FVector &SegmentEndA, const FVector &SegmentStartB, const FVector &SegmentEndB, FVector &out_IntersectionPoint)
 
static CORE_API FVector ClosestPointOnTriangleToPoint (const FVector &Point, const FVector &A, const FVector &B, const FVector &C)
 
static CORE_API FVector ClosestPointOnTetrahedronToPoint (const FVector &Point, const FVector &A, const FVector &B, const FVector &C, const FVector &D)
 
static CORE_API void SphereDistToLine (FVector SphereOrigin, float SphereRadius, FVector LineOrigin, FVector LineDir, FVector &OutClosestPoint)
 
static CORE_API bool GetDistanceWithinConeSegment (FVector Point, FVector ConeStartPoint, FVector ConeLine, float RadiusAtStart, float RadiusAtEnd, float &PercentageOut)
 
static CORE_API bool PointsAreCoplanar (const TArray< FVector > &Points, const float Tolerance=0.1f)
 
static CORE_API float TruncateToHalfIfClose (float F, float Tolerance=UE_SMALL_NUMBER)
 
static CORE_API double TruncateToHalfIfClose (double F, double Tolerance=UE_SMALL_NUMBER)
 
static CORE_API float RoundHalfToEven (float F)
 
static CORE_API double RoundHalfToEven (double F)
 
static CORE_API float RoundHalfFromZero (float F)
 
static CORE_API double RoundHalfFromZero (double F)
 
static CORE_API float RoundHalfToZero (float F)
 
static CORE_API double RoundHalfToZero (double F)
 
static UE_FORCEINLINE_HINT float RoundFromZero (float F)
 
static UE_FORCEINLINE_HINT double RoundFromZero (double F)
 
static UE_FORCEINLINE_HINT float RoundToZero (float F)
 
static UE_FORCEINLINE_HINT double RoundToZero (double F)
 
static UE_FORCEINLINE_HINT float RoundToNegativeInfinity (float F)
 
static UE_FORCEINLINE_HINT double RoundToNegativeInfinity (double F)
 
static UE_FORCEINLINE_HINT float RoundToPositiveInfinity (float F)
 
static UE_FORCEINLINE_HINT double RoundToPositiveInfinity (double F)
 
static CORE_API FString FormatIntToHumanReadable (int32 Val)
 
static CORE_API bool MemoryTest (void *BaseAddress, uint32 NumBytes)
 
static CORE_API bool Eval (FString Str, float &OutValue)
 
static CORE_API FVector GetBaryCentric2D (const FVector &Point, const FVector &A, const FVector &B, const FVector &C)
 
static CORE_API FVector GetBaryCentric2D (const FVector2D &Point, const FVector2D &A, const FVector2D &B, const FVector2D &C)
 
static CORE_API FVector ComputeBaryCentric2D (const FVector &Point, const FVector &A, const FVector &B, const FVector &C)
 
static CORE_API bool ComputeBarycentricTri (const FVector &Point, const FVector &A, const FVector &B, const FVector &C, FVector &OutBarycentric, double Tolerance=UE_DOUBLE_SMALL_NUMBER)
 
static CORE_API FVector4 ComputeBaryCentric3D (const FVector &Point, const FVector &A, const FVector &B, const FVector &C, const FVector &D)
 
template<typename T >
static constexprSmoothStep (T A, T B, T X)
 
static constexpr bool ExtractBoolFromBitfield (const uint8 *Ptr, uint32 Index)
 
static constexpr void SetBoolInBitField (uint8 *Ptr, uint32 Index, bool bSet)
 
static CORE_API void ApplyScaleToFloat (float &Dst, const FVector &DeltaScale, float Magnitude=1.0f)
 
static uint8 Quantize8UnsignedByte (float x)
 
static uint8 Quantize8SignedByte (float x)
 
static constexpr int32 GreatestCommonDivisor (int32 a, int32 b)
 
static constexpr int32 LeastCommonMultiplier (int32 a, int32 b)
 
static CORE_API float PerlinNoise1D (float Value)
 
static CORE_API float PerlinNoise2D (const FVector2D &Location)
 
static CORE_API float PerlinNoise3D (const FVector &Location)
 
template<typename T >
staticWeightedMovingAverage (T CurrentSample, T PreviousSample, T Weight)
 
template<typename T >
staticDynamicWeightedMovingAverage (T CurrentSample, T PreviousSample, T MaxDistance, T MinWeight, T MaxWeight)
 
static CORE_API bool MatrixInverse (FMatrix44f *DstMatrix, const FMatrix44f *SrcMatrix)
 
static CORE_API bool MatrixInverse (FMatrix44d *DstMatrix, const FMatrix44d *SrcMatrix)
 

Static Public Attributes

static CORE_API const uint32 BitFlag [32]
 

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

Member Function Documentation

◆ ApplyScaleToFloat()

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 >
static constexpr 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

◆ BiLerp() [2/2]

template<typename T , typename U >
static UE_FORCEINLINE_HINT 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.

◆ CartesianToPolar() [1/2]

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

Converts given Cartesian coordinate pair to Polar coordinate system.

◆ CartesianToPolar() [2/2]

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

Converts given Cartesian coordinate pair to Polar coordinate system.

◆ CInterpTo()

CORE_API 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 constexpr UE_FORCEINLINE_HINT double FMath::Clamp ( const double  X,
const double  Min,
const double  Max 
)
inlinestaticconstexpr

◆ Clamp() [2/4]

static constexpr UE_FORCEINLINE_HINT 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.

◆ Clamp() [3/4]

static constexpr UE_FORCEINLINE_HINT 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.

◆ Clamp() [4/4]

template<class T >
static constexpr UE_FORCEINLINE_HINT T FMath::Clamp ( const T  X,
const T  MinValue,
const T  MaxValue 
)
inlinestaticconstexpr

Clamps X to be between Min and Max, inclusive

◆ ClampAngle()

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

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()

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() [1/2]

template<typename T >
UE::Math::TVector< T > FMath::ClosestPointOnLine ( const UE::Math::TVector< T > &  LineStart,
const UE::Math::TVector< T > &  LineEnd,
const UE::Math::TVector< T > &  Point 
)

◆ ClosestPointOnLine() [2/2]

template<typename T >
static CORE_API UE::Math::TVector< T > FMath::ClosestPointOnLine ( const UE::Math::TVector< T > &  LineStart,
const UE::Math::TVector< T > &  LineEnd,
const UE::Math::TVector< T > &  Point 
)
static

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

◆ ClosestPointOnSegment() [1/2]

template<typename T >
UE::Math::TVector< T > FMath::ClosestPointOnSegment ( const UE::Math::TVector< T > &  Point,
const UE::Math::TVector< T > &  StartPoint,
const UE::Math::TVector< T > &  EndPoint 
)

◆ ClosestPointOnSegment() [2/2]

template<typename T >
static CORE_API UE::Math::TVector< T > FMath::ClosestPointOnSegment ( const UE::Math::TVector< T > &  Point,
const UE::Math::TVector< T > &  StartPoint,
const UE::Math::TVector< T > &  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() [1/2]

template<typename T >
UE::Math::TVector2< T > FMath::ClosestPointOnSegment2D ( const UE::Math::TVector2< T > &  Point,
const UE::Math::TVector2< T > &  StartPoint,
const UE::Math::TVector2< T > &  EndPoint 
)

◆ ClosestPointOnSegment2D() [2/2]

template<typename T >
static CORE_API UE::Math::TVector2< T > FMath::ClosestPointOnSegment2D ( const UE::Math::TVector2< T > &  Point,
const UE::Math::TVector2< T > &  StartPoint,
const UE::Math::TVector2< T > &  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()

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()

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()

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 3D triangle. Note: Prefer the more accurately-named ComputeBarycentricTri instead.

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()

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

◆ ComputeBarycentricTri()

bool FMath::ComputeBarycentricTri ( const FVector Point,
const FVector A,
const FVector B,
const FVector C,
FVector OutBarycentric,
double  Tolerance = UE_DOUBLE_SMALL_NUMBER 
)
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
OutBarycentricVector 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
ToleranceTolerance for ignoring too-small triangles
Returns
false if the result could not be computed (occurs when the triangle area is too small)

◆ ComputeBoundingSphereForCone()

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

Computes minimal bounding sphere encompassing given cone

◆ ComputeProjectedSphereScissorRect()

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.

◆ Cube()

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

Cubes the value

◆ CubicCRSplineInterp()

template<class U >
static constexpr 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

◆ CubicCRSplineInterpSafe()

template<class U >
static constexpr 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

◆ CubicInterp() [1/2]

template<typename T , typename U >
static constexpr 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

◆ CubicInterp() [2/2]

template<typename T , typename U >
static UE_FORCEINLINE_HINT 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.

◆ CubicInterpDerivative()

template<typename T , UE::CFloatingPoint U>
static constexpr 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

◆ CubicInterpSecondDerivative()

template<typename T , UE::CFloatingPoint U>
static constexpr 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

◆ DegreesToRadians() [1/3]

static constexpr UE_FORCEINLINE_HINT double FMath::DegreesToRadians ( double const &  DegVal)
inlinestaticconstexpr

◆ DegreesToRadians() [2/3]

static constexpr UE_FORCEINLINE_HINT float FMath::DegreesToRadians ( float const &  DegVal)
inlinestaticconstexpr

◆ DegreesToRadians() [3/3]

template<class T >
static constexpr UE_FORCEINLINE_HINT 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.

◆ DivideAndRoundDown()

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

Divides two integers and rounds down

◆ DivideAndRoundNearest()

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

Divides two integers and rounds to nearest

◆ DivideAndRoundUp()

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

Divides two integers and rounds up

◆ DynamicWeightedMovingAverage()

template<typename T >
static T FMath::DynamicWeightedMovingAverage ( CurrentSample,
PreviousSample,
MaxDistance,
MinWeight,
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

◆ Eval()

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.

◆ ExtractBoolFromBitfield()

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

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

◆ FastAsin() [1/2]

static UE_FORCEINLINE_HINT double FMath::FastAsin ( double  Value)
inlinestatic

◆ FastAsin() [2/2]

static float FMath::FastAsin ( float  Value)
inlinestatic

Computes the ASin of a scalar value.

Parameters
Valueinput angle
Returns
ASin of Value

◆ FindDeltaAngleDegrees()

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

Find the smallest angle between two headings (in degrees)

◆ FindDeltaAngleRadians()

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

Find the smallest angle between two headings (in radians)

◆ FInterpConstantTo()

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

Interpolate float from Current to Target with constant step

◆ FInterpTo()

template<typename T1 , typename T2 = T1, typename T3 = T2, typename T4 = T3>
static 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.

◆ FixedTurn()

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_FORCEINLINE_HINT double FMath::Floor ( double  F)
inlinestatic

Converts a double to a nearest less or equal integer.

◆ Floor() [2/3]

static UE_FORCEINLINE_HINT float FMath::Floor ( float  F)
inlinestatic

Converts a float to a nearest less or equal integer.

◆ Floor() [3/3]

template<UE::CIntegral IntegralType>
static constexpr UE_FORCEINLINE_HINT IntegralType FMath::Floor ( IntegralType  I)
inlinestaticconstexpr

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

◆ FormatIntToHumanReadable()

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_FORCEINLINE_HINT double FMath::FRandRange ( double  InMin,
double  InMax 
)
inlinestatic

Util to generate a random number in a range.

◆ FRandRange() [2/2]

static UE_FORCEINLINE_HINT float FMath::FRandRange ( float  InMin,
float  InMax 
)
inlinestatic

Util to generate a random number in a range.

◆ GetAzimuthAndElevation()

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]

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]

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()

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()

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 T FMath::GetMappedRangeValueClamped ( const TRange< T > &  InputRange,
const TRange< T > &  OutputRange,
const T  Value 
)
inlinestatic

◆ GetMappedRangeValueClamped() [2/2]

template<typename T , typename T2 >
static 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.

◆ GetMappedRangeValueUnclamped()

template<typename T , typename T2 >
static UE_FORCEINLINE_HINT 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.

◆ GetRangePct() [1/3]

static constexpr auto FMath::GetRangePct ( MinValue,
MaxValue,
T2  Value 
)
inlinestaticconstexpr

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

◆ GetRangePct() [2/3]

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

◆ GetRangePct() [3/3]

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

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

◆ GetRangeValue() [1/2]

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

◆ GetRangeValue() [2/2]

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

Basically a Vector2d version of Lerp.

◆ GetReflectionVector()

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()

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 constexpr int32 FMath::GreatestCommonDivisor ( int32  a,
int32  b 
)
inlinestaticconstexpr

◆ GridSnap()

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

Snaps a value to the nearest grid multiple

◆ InterpCircularIn()

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

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

◆ InterpCircularInOut()

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

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

◆ InterpCircularOut()

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

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

◆ InterpEaseIn()

template<class T >
static 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.

◆ InterpEaseInOut()

template<class T >
static 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.

◆ InterpEaseOut()

template<class T >
static 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.

◆ InterpExpoIn()

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

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

◆ InterpExpoInOut()

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

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

◆ InterpExpoOut()

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

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

◆ InterpSinIn()

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

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

◆ InterpSinInOut()

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

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

◆ InterpSinOut()

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

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

◆ InterpStep()

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

Interpolation between A and B, applying a step function.

◆ IntersectPlanes2() [1/2]

template<typename FReal >
static 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

◆ IntersectPlanes3() [1/2]

template<typename FReal >
static 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

◆ InvExpApprox()

template<class T >
static constexpr T FMath::InvExpApprox ( 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).

◆ IsNearlyEqual() [1/2]

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

◆ IsNearlyEqual() [2/2]

static UE_FORCEINLINE_HINT 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

◆ IsNearlyEqualByULP() [1/2]

static UE_FORCEINLINE_HINT 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.

◆ IsNearlyEqualByULP() [2/2]

static UE_FORCEINLINE_HINT 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.

◆ IsNearlyZero() [1/2]

static UE_FORCEINLINE_HINT 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

◆ IsNearlyZero() [2/2]

static UE_FORCEINLINE_HINT 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

◆ IsPowerOfTwo()

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

Checks whether a number is a power of two.

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

◆ IsWithin()

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

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

◆ IsWithinInclusive()

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

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

◆ LeastCommonMultiplier()

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

◆ Lerp() [1/3]

template<typename T , typename U >
static constexpr UE_FORCEINLINE_HINT 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

◆ Lerp() [2/3]

template<typename T , typename U >
static UE_FORCEINLINE_HINT 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.

◆ Lerp() [3/3]

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

◆ LerpRange() [1/2]

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

◆ LerpRange() [2/2]

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

◆ LerpStable() [1/3]

template<class T >
static constexpr UE_FORCEINLINE_HINT 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

◆ LerpStable() [2/3]

template<class T >
static constexpr UE_FORCEINLINE_HINT 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

◆ LerpStable() [3/3]

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

◆ LineBoxIntersection() [1/2]

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 > &  Direction 
)
inlinestatic

Determines whether a line intersects a box.

◆ LineBoxIntersection() [2/2]

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 > &  Direction,
const UE::Math::TVector< FReal > &  OneOverDirection 
)
inlinestatic

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

◆ LineBoxIntersection2D()

template<typename FReal >
bool FMath::LineBoxIntersection2D ( const UE::Math::TBox2< FReal > &  Box,
const UE::Math::TVector2< FReal > &  Start,
const UE::Math::TVector2< FReal > &  End 
)
inlinestatic

Determines whether a line intersects a 2D box.

◆ LineExtentBoxIntersection()

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::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::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

◆ 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

◆ LineSphereIntersection() [1/2]

template<typename FReal >
static 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,
Length,
const UE::Math::TVector< T > &  Origin,
Radius 
)
inline

◆ Log2() [1/2]

static 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

◆ Log2() [2/2]

static 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

◆ MakePulsatingValue()

static 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)

◆ MatrixInverse() [1/2]

bool FMath::MatrixInverse ( FMatrix44d DstMatrix,
const FMatrix44d SrcMatrix 
)
static

Calculate the inverse of an FMatrix44.

Parameters
DstMatrixFMatrix44 pointer to where the result should be stored
SrcMatrixFMatrix44 pointer to the Matrix to be inversed
Returns
bool returns false if matrix is not invertable and stores identity

Src == Dst is allowed

◆ MatrixInverse() [2/2]

bool FMath::MatrixInverse ( FMatrix44f DstMatrix,
const FMatrix44f SrcMatrix 
)
static

Calculate the inverse of an FMatrix44. Src == Dst is allowed

Parameters
DstMatrixFMatrix44 pointer to where the result should be stored
SrcMatrixFMatrix44 pointer to the Matrix to be inversed
Returns
bool returns false if matrix is not invertable and stores identity

Do not call this directly, use VectorMatrixInverse or Matrix::Inverse this is the fallback scalar implementation used by VectorMatrixInverse

◆ Max3()

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

Returns highest of 3 values

◆ Max3Index()

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

◆ MemoryTest()

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 constexpr UE_FORCEINLINE_HINT T FMath::Min3 ( const T  A,
const T  B,
const T  C 
)
inlinestaticconstexpr

Returns lowest of 3 values

◆ Min3Index()

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

Returns index of the lowest value

◆ 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.

◆ Modulo()

template<typename ValueType , typename BaseType >
static constexpr auto FMath::Modulo ( ValueType  Value,
BaseType  Base 
)
inlinestaticconstexpr

◆ PerlinNoise1D()

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()

float FMath::PerlinNoise2D ( const FVector2D Location)
static

Generates a 2D 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()

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()

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()

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()

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

Determines whether a point is inside a box.

◆ PointDistToLine() [1/2]

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

◆ PointDistToLine() [2/2]

CORE_API 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()

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()

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()

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 void FMath::PolarToCartesian ( const T  Rad,
const T  Ang,
T &  OutX,
T &  OutY 
)
inlinestatic

Converts given Polar coordinate pair to Cartesian coordinate system.

◆ PolarToCartesian() [2/2]

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

Converts given Polar coordinate pair to Cartesian coordinate system.

◆ QInterpConstantTo()

template<class T >
template CORE_API UE::Math::TQuat< double > FMath::QInterpConstantTo< double > ( 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 >
template CORE_API UE::Math::TQuat< double > FMath::QInterpTo< double > ( 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 uint8 FMath::Quantize8SignedByte ( float  x)
inlinestatic

◆ Quantize8UnsignedByte()

static uint8 FMath::Quantize8UnsignedByte ( float  x)
inlinestatic

◆ RadiansToDegrees() [1/3]

static constexpr UE_FORCEINLINE_HINT double FMath::RadiansToDegrees ( double const &  RadVal)
inlinestaticconstexpr

◆ RadiansToDegrees() [2/3]

static constexpr UE_FORCEINLINE_HINT float FMath::RadiansToDegrees ( float const &  RadVal)
inlinestaticconstexpr

◆ RadiansToDegrees() [3/3]

template<class T >
static constexpr UE_FORCEINLINE_HINT 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.

◆ RandBool()

static UE_FORCEINLINE_HINT bool FMath::RandBool ( )
inlinestatic

Util to generate a random boolean.

◆ RandHelper()

static UE_FORCEINLINE_HINT int32 FMath::RandHelper ( int32  A)
inlinestatic

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

◆ RandHelper64()

static UE_FORCEINLINE_HINT int64 FMath::RandHelper64 ( int64  A)
inlinestatic

◆ RandPointInBox()

FVector FMath::RandPointInBox ( const FBox Box)
static

Returns a random point within the passed in bounding box

◆ RandPointInCircle()

FVector2D FMath::RandPointInCircle ( float  CircleRadius)
static

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

◆ RandRange() [1/4]

static UE_FORCEINLINE_HINT double FMath::RandRange ( double  InMin,
double  InMax 
)
inlinestatic

◆ RandRange() [2/4]

static UE_FORCEINLINE_HINT 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.

◆ RandRange() [3/4]

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

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

◆ RandRange() [4/4]

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

◆ RayPlaneIntersection() [1/2]

template<typename FReal >
static 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

◆ RayPlaneIntersectionParam() [1/2]

template<typename FReal >
static 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

◆ 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()

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

Interpolate rotator from Current to Target with constant step

◆ RInterpTo()

CORE_API 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_FORCEINLINE_HINT double FMath::RoundFromZero ( double  F)
inlinestatic

◆ RoundFromZero() [2/2]

static UE_FORCEINLINE_HINT 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

◆ RoundHalfFromZero() [1/2]

double FMath::RoundHalfFromZero ( double  F)
static

◆ RoundHalfFromZero() [2/2]

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]

double FMath::RoundHalfToEven ( double  F)
static

◆ RoundHalfToEven() [2/2]

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]

double FMath::RoundHalfToZero ( double  F)
static

◆ RoundHalfToZero() [2/2]

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_FORCEINLINE_HINT double FMath::RoundToNegativeInfinity ( double  F)
inlinestatic

◆ RoundToNegativeInfinity() [2/2]

static UE_FORCEINLINE_HINT 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

◆ RoundToPositiveInfinity() [1/2]

static UE_FORCEINLINE_HINT double FMath::RoundToPositiveInfinity ( double  F)
inlinestatic

◆ RoundToPositiveInfinity() [2/2]

static UE_FORCEINLINE_HINT 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

◆ RoundToZero() [1/2]

static UE_FORCEINLINE_HINT double FMath::RoundToZero ( double  F)
inlinestatic

◆ RoundToZero() [2/2]

static UE_FORCEINLINE_HINT 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

◆ SegmentDistToSegment()

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() [1/2]

template<typename T >
void FMath::SegmentDistToSegmentSafe ( UE::Math::TVector< T >  A1,
UE::Math::TVector< T >  B1,
UE::Math::TVector< T >  A2,
UE::Math::TVector< T >  B2,
UE::Math::TVector< T > &  OutP1,
UE::Math::TVector< T > &  OutP2 
)

◆ SegmentDistToSegmentSafe() [2/2]

template<typename T >
static CORE_API void FMath::SegmentDistToSegmentSafe ( UE::Math::TVector< T >  A1,
UE::Math::TVector< T >  B1,
UE::Math::TVector< T >  A2,
UE::Math::TVector< T >  B2,
UE::Math::TVector< T > &  OutP1,
UE::Math::TVector< T > &  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()

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()

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()

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

◆ SinCos() [1/3]

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

◆ SinCos() [2/3]

template<UE::CFloatingPoint T>
static constexpr void FMath::SinCos ( std::decay_t< T > *  ScalarSin,
std::decay_t< T > *  ScalarCos,
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

◆ SinCos() [3/3]

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

◆ SmoothStep()

template<typename T >
static constexpr T FMath::SmoothStep ( A,
B,
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

◆ SphereAABBIntersection() [1/2]

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

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

◆ SphereAABBIntersection() [2/2]

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

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()

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

from http://www.geometrictools.com/Documentation/IntersectionSphereCone.pdf (Copyright c 1998-2008. All Rights Reserved.) http://www.geometrictools.com (boost license)

◆ SphereDistToLine()

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.

◆ 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.

◆ Square()

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

Multiples value by itself

◆ TruncateToHalfIfClose() [1/2]

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

◆ TruncateToHalfIfClose() [2/2]

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<UE::CFloatingPoint T>
static constexpr T FMath::UnwindDegrees ( A)
inlinestaticconstexpr

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

◆ UnwindRadians()

template<UE::CFloatingPoint T>
static constexpr T FMath::UnwindRadians ( A)
inlinestaticconstexpr

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

◆ Vector2DInterpConstantTo()

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

Interpolate vector2D from Current to Target with constant step

◆ Vector2DInterpTo()

template<typename T >
template CORE_API UE::Math::TVector2< double > FMath::Vector2DInterpTo ( const UE::Math::TVector2< T > &  Current,
const UE::Math::TVector2< T > &  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()

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

Interpolate vector from Current to Target with constant step

◆ VInterpNormalRotationTo()

CORE_API 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()

CORE_API 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.

◆ VRandCone() [1/2]

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]

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 T FMath::WeightedMovingAverage ( CurrentSample,
PreviousSample,
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

◆ WindRelativeAnglesDegrees() [1/2]

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

◆ WindRelativeAnglesDegrees() [2/2]

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<UE::CFloatingPoint T>
static constexpr UE_FORCEINLINE_HINT 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.

◆ WrapExclusive()

template<UE::CIntegral T>
static constexpr T FMath::WrapExclusive ( const T  X,
const T  Min,
const T  Max 
)
inlinestaticconstexpr

Wraps X to be between Min and Max, exclusive. Will never return Max.

Member Data Documentation

◆ BitFlag

CORE_API const uint32 FMath::BitFlag
static
Initial value:
=
{
(1U << 0), (1U << 1), (1U << 2), (1U << 3),
(1U << 4), (1U << 5), (1U << 6), (1U << 7),
(1U << 8), (1U << 9), (1U << 10), (1U << 11),
(1U << 12), (1U << 13), (1U << 14), (1U << 15),
(1U << 16), (1U << 17), (1U << 18), (1U << 19),
(1U << 20), (1U << 21), (1U << 22), (1U << 23),
(1U << 24), (1U << 25), (1U << 26), (1U << 27),
(1U << 28), (1U << 29), (1U << 30), (1U << 31),
}

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


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