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

#include <UnrealMathUtility.h>

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

Static Public Member Functions

static FORCEINLINE int32 RandHelper (int32 A)
 
static FORCEINLINE int32 RandRange (int32 Min, int32 Max)
 
static FORCEINLINE float RandRange (float InMin, float InMax)
 
static FORCEINLINE float FRandRange (float InMin, float InMax)
 
static FORCEINLINE bool RandBool ()
 
template<typename T >
static FORCEINLINE bool IsPowerOfTwo (T Value)
 
template<class T >
static FORCEINLINE T Max3 (const T A, const T B, const T C)
 
template<class T >
static FORCEINLINE T Min3 (const T A, const T B, const T C)
 
template<class T >
static FORCEINLINE T Square (const T A)
 
template<class T >
static FORCEINLINE T Clamp (const T X, const T Min, const T Max)
 
template<class T >
static FORCEINLINE T DivideAndRoundUp (T Dividend, T Divisor)
 
template<class T >
static FORCEINLINE T DivideAndRoundDown (T Dividend, T Divisor)
 
static FORCEINLINE void SinCos (float *ScalarSin, float *ScalarCos, float Value)
 
static FORCEINLINE float FastAsin (float Value)
 
template<class T >
static FORCEINLINE auto RadiansToDegrees (T const &RadVal) -> decltype(RadVal *(180.f/PI))
 
template<class T >
static FORCEINLINE auto DegreesToRadians (T const &DegVal) -> decltype(DegVal *(PI/180.f))
 
static float FindDeltaAngleDegrees (float A1, float A2)
 
static float FindDeltaAngleRadians (float A1, float A2)
 
static float UnwindRadians (float A)
 
static float UnwindDegrees (float A)
 
static FORCEINLINE void PolarToCartesian (const float Rad, const float Ang, float &OutX, float &OutY)
 
template<class T , class U >
static T Lerp (const T &A, const T &B, const U &Alpha)
 
template<class T >
static T LerpStable (const T &A, const T &B, double Alpha)
 
template<class T >
static T LerpStable (const T &A, const T &B, float Alpha)
 
template<class T , class U >
static T BiLerp (const T &P00, const T &P10, const T &P01, const T &P11, const U &FracX, const U &FracY)
 
template<class T , class U >
static T CubicInterp (const T &P0, const T &T0, const T &P1, const T &T1, const U &A)
 
template<class T , class U >
static T CubicInterpDerivative (const T &P0, const T &T0, const T &P1, const T &T1, const U &A)
 
template<class T , class U >
static T CubicInterpSecondDerivative (const T &P0, const T &T0, const T &P1, const T &T1, const U &A)
 
template<class T >
static T InterpEaseIn (const T &A, const T &B, float Alpha, float Exp)
 
template<class T >
static T InterpEaseOut (const T &A, const T &B, float Alpha, float Exp)
 
template<class T >
static T InterpEaseInOut (const T &A, const T &B, float Alpha, float Exp)
 
template<class T >
static T InterpStep (const T &A, const T &B, float Alpha, int32 Steps)
 
template<class T >
static T InterpSinIn (const T &A, const T &B, float Alpha)
 
template<class T >
static T InterpSinOut (const T &A, const T &B, float Alpha)
 
template<class T >
static T InterpSinInOut (const T &A, const T &B, float Alpha)
 
template<class T >
static T InterpExpoIn (const T &A, const T &B, float Alpha)
 
template<class T >
static T InterpExpoOut (const T &A, const T &B, float Alpha)
 
template<class T >
static T InterpExpoInOut (const T &A, const T &B, float Alpha)
 
template<class T >
static T InterpCircularIn (const T &A, const T &B, float Alpha)
 
template<class T >
static T InterpCircularOut (const T &A, const T &B, float Alpha)
 
template<class T >
static T InterpCircularInOut (const T &A, const T &B, float Alpha)
 
template<class U >
static U CubicCRSplineInterp (const U &P0, const U &P1, const U &P2, const U &P3, const float T0, const float T1, const float T2, const float T3, const float T)
 
static FORCEINLINE float RoundFromZero (float F)
 
static FORCEINLINE double RoundFromZero (double F)
 
static FORCEINLINE float RoundToZero (float F)
 
static FORCEINLINE double RoundToZero (double F)
 
static FORCEINLINE float RoundToNegativeInfinity (float F)
 
static FORCEINLINE double RoundToNegativeInfinity (double F)
 
static FORCEINLINE float RoundToPositiveInfinity (float F)
 
static FORCEINLINE double RoundToPositiveInfinity (double F)
 
static float SmoothStep (float A, float B, float X)
 
static int32 GreatestCommonDivisor (int32 a, int32 b)
 
static int32 LeastCommonMultiplier (int32 a, int32 b)
 
- Static Public Member Functions inherited from FGenericPlatformMath
static CONSTEXPR FORCEINLINE int32 TruncToInt (float F)
 
static CONSTEXPR FORCEINLINE float TruncToFloat (float F)
 
static FORCEINLINE int32 FloorToInt (float F)
 
static FORCEINLINE float FloorToFloat (float F)
 
static FORCEINLINE double FloorToDouble (double F)
 
static FORCEINLINE int32 RoundToInt (float F)
 
static FORCEINLINE float RoundToFloat (float F)
 
static FORCEINLINE double RoundToDouble (double F)
 
static FORCEINLINE int32 CeilToInt (float F)
 
static FORCEINLINE float CeilToFloat (float F)
 
static FORCEINLINE double CeilToDouble (double F)
 
static FORCEINLINE float Fractional (float Value)
 
static FORCEINLINE float Frac (float Value)
 
static FORCEINLINE float Modf (const float InValue, float *OutIntPart)
 
static FORCEINLINE double Modf (const double InValue, double *OutIntPart)
 
static FORCEINLINE float Exp (float Value)
 
static FORCEINLINE float Exp2 (float Value)
 
static FORCEINLINE float Loge (float Value)
 
static FORCEINLINE float LogX (float Base, float Value)
 
static FORCEINLINE float Log2 (float Value)
 
static FORCEINLINE float Fmod (float X, float Y)
 
static FORCEINLINE float Sin (float Value)
 
static FORCEINLINE float Asin (float Value)
 
static FORCEINLINE float Sinh (float Value)
 
static FORCEINLINE float Cos (float Value)
 
static FORCEINLINE float Acos (float Value)
 
static FORCEINLINE float Tan (float Value)
 
static FORCEINLINE float Atan (float Value)
 
static FORCEINLINE float Sqrt (float Value)
 
static FORCEINLINE float Pow (float A, float B)
 
static FORCEINLINE float InvSqrt (float F)
 
static FORCEINLINE float InvSqrtEst (float F)
 
static FORCEINLINE bool IsNaN (float A)
 
static FORCEINLINE bool IsFinite (float A)
 
static FORCEINLINE bool IsNegativeFloat (const float &A)
 
static FORCEINLINE bool IsNegativeDouble (const double &A)
 
static FORCEINLINE int32 Rand ()
 
static FORCEINLINE void RandInit (int32 Seed)
 
static FORCEINLINE float FRand ()
 
static FORCEINLINE uint32 FloorLog2 (uint32 Value)
 
static FORCEINLINE uint64 FloorLog2_64 (uint64 Value)
 
static FORCEINLINE uint32 CountLeadingZeros (uint32 Value)
 
static FORCEINLINE uint64 CountLeadingZeros64 (uint64 Value)
 
static FORCEINLINE uint32 CountTrailingZeros (uint32 Value)
 
static FORCEINLINE uint32 CeilLogTwo (uint32 Arg)
 
static FORCEINLINE uint64 CeilLogTwo64 (uint64 Arg)
 
static FORCEINLINE uint32 RoundUpToPowerOfTwo (uint32 Arg)
 
static FORCEINLINE uint32 MortonCode2 (uint32 x)
 
static FORCEINLINE uint32 ReverseMortonCode2 (uint32 x)
 
static FORCEINLINE uint32 MortonCode3 (uint32 x)
 
static FORCEINLINE uint32 ReverseMortonCode3 (uint32 x)
 
static CONSTEXPR FORCEINLINE float FloatSelect (float Comparand, float ValueGEZero, float ValueLTZero)
 
static CONSTEXPR FORCEINLINE double FloatSelect (double Comparand, double ValueGEZero, double ValueLTZero)
 
template<class T >
static CONSTEXPR FORCEINLINE T Abs (const T A)
 
template<class T >
static CONSTEXPR FORCEINLINE T Sign (const T A)
 
template<class T >
static CONSTEXPR FORCEINLINE T Max (const T A, const T B)
 
template<class T >
static CONSTEXPR FORCEINLINE T Min (const T A, const T B)
 
template<class T >
static FORCEINLINE T Min (const TArray< T > &Values, int32 *MinIndex=NULL)
 
template<class T >
static FORCEINLINE T Max (const TArray< T > &Values, int32 *MaxIndex=NULL)
 
static FORCEINLINE int32 CountBits (uint64 Bits)
 

Additional Inherited Members

- Public Member Functions inherited from FGenericPlatformMath
template<>
FORCEINLINE float Abs (const float A)
 

Detailed Description

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

Definition at line 69 of file UnrealMathUtility.h.

Member Function Documentation

◆ BiLerp()

template<class T , class U >
static T FMath::BiLerp ( const T & P00,
const T & P10,
const T & P01,
const T & P11,
const U & FracX,
const U & FracY )
inlinestatic

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

Definition at line 378 of file UnrealMathUtility.h.

◆ Clamp()

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

Clamps X to be between Min and Max, inclusive

Definition at line 143 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

◆ CubicCRSplineInterp()

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

Definition at line 576 of file UnrealMathUtility.h.

◆ CubicInterp()

template<class T , class U >
static T FMath::CubicInterp ( const T & P0,
const T & T0,
const T & P1,
const T & T1,
const U & A )
inlinestatic

Performs a cubic interpolation

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

Definition at line 397 of file UnrealMathUtility.h.

◆ CubicInterpDerivative()

template<class T , class U >
static T FMath::CubicInterpDerivative ( const T & P0,
const T & T0,
const T & P1,
const T & T1,
const U & A )
inlinestatic

Performs a first derivative cubic interpolation

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

Definition at line 415 of file UnrealMathUtility.h.

◆ CubicInterpSecondDerivative()

template<class T , class U >
static T FMath::CubicInterpSecondDerivative ( const T & P0,
const T & T0,
const T & P1,
const T & T1,
const U & A )
inlinestatic

Performs a second derivative cubic interpolation

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

Definition at line 436 of file UnrealMathUtility.h.

◆ DegreesToRadians()

template<class T >
static FORCEINLINE auto FMath::DegreesToRadians ( T const & DegVal) -> decltype(DegVal * (PI / 180.f))
inlinestatic

Converts degrees to radians.

Parameters
DegValValue in degrees.
Returns
Value in radians.

Definition at line 265 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

◆ DivideAndRoundDown()

template<class T >
static FORCEINLINE T FMath::DivideAndRoundDown ( T Dividend,
T Divisor )
inlinestatic

Definition at line 156 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

◆ DivideAndRoundUp()

template<class T >
static FORCEINLINE T FMath::DivideAndRoundUp ( T Dividend,
T Divisor )
inlinestatic

Divides two integers and rounds up

Definition at line 150 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

◆ FastAsin()

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

Computes the ASin of a scalar float.

Parameters
Valueinput angle
Returns
ASin of Value

Definition at line 225 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ FindDeltaAngleDegrees()

static float FMath::FindDeltaAngleDegrees ( float A1,
float A2 )
inlinestatic

Find the smallest angle between two headings (in degrees)

Definition at line 271 of file UnrealMathUtility.h.

◆ FindDeltaAngleRadians()

static float FMath::FindDeltaAngleRadians ( float A1,
float A2 )
inlinestatic

Find the smallest angle between two headings (in radians)

Definition at line 294 of file UnrealMathUtility.h.

◆ FRandRange()

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

Util to generate a random number in a range.

Definition at line 95 of file UnrealMathUtility.h.

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

◆ GreatestCommonDivisor()

static int32 FMath::GreatestCommonDivisor ( int32 a,
int32 b )
inlinestatic

Definition at line 682 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

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

Definition at line 540 of file UnrealMathUtility.h.

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

Definition at line 557 of file UnrealMathUtility.h.

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

Definition at line 548 of file UnrealMathUtility.h.

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

Definition at line 446 of file UnrealMathUtility.h.

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

Definition at line 462 of file UnrealMathUtility.h.

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

Definition at line 454 of file UnrealMathUtility.h.

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

Definition at line 515 of file UnrealMathUtility.h.

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

Definition at line 531 of file UnrealMathUtility.h.

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

Definition at line 523 of file UnrealMathUtility.h.

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

Definition at line 490 of file UnrealMathUtility.h.

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

Definition at line 506 of file UnrealMathUtility.h.

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

Definition at line 498 of file UnrealMathUtility.h.

◆ InterpStep()

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

Interpolation between A and B, applying a step function.

Definition at line 471 of file UnrealMathUtility.h.

◆ IsPowerOfTwo()

template<typename T >
static FORCEINLINE bool FMath::IsPowerOfTwo ( T Value)
inlinestatic

Checks whether a number is a power of two.

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

Definition at line 112 of file UnrealMathUtility.h.

◆ LeastCommonMultiplier()

static int32 FMath::LeastCommonMultiplier ( int32 a,
int32 b )
inlinestatic

Definition at line 695 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ Lerp()

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

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

Definition at line 357 of file UnrealMathUtility.h.

◆ LerpStable() [1/2]

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

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

Definition at line 364 of file UnrealMathUtility.h.

◆ LerpStable() [2/2]

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

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

Definition at line 371 of file UnrealMathUtility.h.

◆ Max3()

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

Returns highest of 3 values

Definition at line 122 of file UnrealMathUtility.h.

◆ Min3()

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

Returns lowest of 3 values

Definition at line 129 of file UnrealMathUtility.h.

◆ PolarToCartesian()

static FORCEINLINE void FMath::PolarToCartesian ( const float Rad,
const float Ang,
float & OutX,
float & OutY )
inlinestatic

Converts given Polar coordinate pair to Cartesian coordinate system.

Definition at line 349 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ RadiansToDegrees()

template<class T >
static FORCEINLINE auto FMath::RadiansToDegrees ( T const & RadVal) -> decltype(RadVal * (180.f / PI))
inlinestatic

Converts radians to degrees.

Parameters
RadValValue in radians.
Returns
Value in degrees.

Definition at line 254 of file UnrealMathUtility.h.

◆ RandBool()

static FORCEINLINE bool FMath::RandBool ( )
inlinestatic

Util to generate a random boolean.

Definition at line 101 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ RandHelper()

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

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

Definition at line 74 of file UnrealMathUtility.h.

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

◆ RandRange() [1/2]

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

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

Definition at line 89 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ RandRange() [2/2]

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

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

Definition at line 82 of file UnrealMathUtility.h.

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

◆ RoundFromZero() [1/2]

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

Definition at line 607 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ RoundFromZero() [2/2]

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

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

Parameters
FFloating point value to convert
Returns
The rounded integer

Definition at line 602 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ RoundToNegativeInfinity() [1/2]

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

Definition at line 637 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ RoundToNegativeInfinity() [2/2]

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

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

Parameters
FFloating point value to convert
Returns
The rounded integer

Definition at line 632 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ RoundToPositiveInfinity() [1/2]

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

Definition at line 652 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ RoundToPositiveInfinity() [2/2]

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

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

Parameters
FFloating point value to convert
Returns
The rounded integer

Definition at line 647 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ RoundToZero() [1/2]

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

Definition at line 622 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ RoundToZero() [2/2]

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

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

Parameters
FFloating point value to convert
Returns
The rounded integer

Definition at line 617 of file UnrealMathUtility.h.

+ Here is the call graph for this function:

◆ SinCos()

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

Computes the sine and cosine of a scalar float.

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

Definition at line 168 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

◆ SmoothStep()

static float FMath::SmoothStep ( float A,
float B,
float X )
inlinestatic

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

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

Definition at line 667 of file UnrealMathUtility.h.

◆ Square()

template<class T >
static FORCEINLINE T FMath::Square ( const T A)
inlinestatic

Multiples value by itself

Definition at line 136 of file UnrealMathUtility.h.

+ Here is the caller graph for this function:

◆ UnwindDegrees()

static float FMath::UnwindDegrees ( float A)
inlinestatic

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

Definition at line 333 of file UnrealMathUtility.h.

◆ UnwindRadians()

static float FMath::UnwindRadians ( float A)
inlinestatic

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

Definition at line 317 of file UnrealMathUtility.h.


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