Static Public Member Functions | List of all members
UBPUtilsMathLibrary Class Reference

Static Public Member Functions

static float AddToFloat (UPARAM(ref) float &A, const float B)
 Adds to a given float in-place (equivalent to +=) More...
 
static void AddToFloatWithLimit (UPARAM(ref) float &A, const float B, const float Limit, float &Result, bool &HitLimit)
 Adds to a given float in-place (+=) and clamps it to the specified limit. More...
 
static float FloatAverage (const float A, const float B)
 Returns the average of two floats. More...
 
static float FloatArrayAverage (const TArray< float > &Array)
 Returns the average of an array of floats. More...
 
static float FloatArraySum (const TArray< float > &Array)
 Returns the sum of an array of floats. More...
 
static int32 AddToInt (UPARAM(ref) int32 &A, const int32 B)
 Adds to a given int in-place (equivalent to +=) More...
 
static void AddToIntWithLimit (UPARAM(ref) int32 &A, const int32 B, const int32 Limit, int32 &Result, bool &HitLimit)
 Adds to a given int in-place (+=) and clamps it to the specified limit. More...
 
static int32 IntArraySum (const TArray< int32 > &Array)
 Returns the sum of an array of ints. More...
 
static float AngleDelta (const float A, const float B)
 Returns the signed shortest distance between two angles. More...
 
static bool IsPointInBox2D (const FVector2D Point, const FBox2D Box)
 Returns whether a point is inside the given box. More...
 
static int32 SystemRand ()
 Returns a random integer using the system rand() function. More...
 
static void FindClosestPoint (const FVector Point, const TArray< FVector > Points, FVector &Closest, int32 &ClosestIndex)
 Finds the closest point in a set. More...
 
static void ClampIntReflect (const int32 Value, const int32 Min, const int32 Max, int32 &Result, bool &Reflected)
 Clamps an int to the specified range, reflecting overshoots back into the range. More...
 
static float AngleBetweenVectors (const FVector A, const FVector B)
 Gets the angle (in degrees) between two vectors. More...
 
static float MapAngleTo180 (const float Value)
 Remaps an angle to [-180°, 180°]. More...
 
static float ClampZeroToOne (const float Value)
 Compact shortcut to clamp a float to [0, 1]. More...
 

Member Function Documentation

◆ AddToFloat()

float UBPUtilsMathLibrary::AddToFloat ( UPARAM(ref) float &  A,
const float  B 
)
static

Adds to a given float in-place (equivalent to +=)

Parameters
AThe float to add to
BThe value to add
Returns
The new value
math-float-addto.png

◆ AddToFloatWithLimit()

void UBPUtilsMathLibrary::AddToFloatWithLimit ( UPARAM(ref) float &  A,
const float  B,
const float  Limit,
float &  Result,
bool &  HitLimit 
)
static

Adds to a given float in-place (+=) and clamps it to the specified limit.

Parameters
AThe float to add to
BThe value to add
LimitThe limit to clamp the value to
Return values
ResultThe new value
HitLimitTrue if the addition exceeded the given limit
math-float-addtolimit.png

◆ AddToInt()

int32 UBPUtilsMathLibrary::AddToInt ( UPARAM(ref) int32 &  A,
const int32  B 
)
static

Adds to a given int in-place (equivalent to +=)

Parameters
AThe integer to add to
BThe value to add
Returns
The new value
math-int-addto.png

◆ AddToIntWithLimit()

void UBPUtilsMathLibrary::AddToIntWithLimit ( UPARAM(ref) int32 &  A,
const int32  B,
const int32  Limit,
int32 &  Result,
bool &  HitLimit 
)
static

Adds to a given int in-place (+=) and clamps it to the specified limit.

Parameters
AThe int to add to
BThe value to add
LimitThe limit to clamp the value to
Return values
ResultThe new value
HitLimitTrue if the addition exceeded the given limit
math-int-addtolimit.png

◆ AngleBetweenVectors()

float UBPUtilsMathLibrary::AngleBetweenVectors ( const FVector  A,
const FVector  B 
)
static

Gets the angle (in degrees) between two vectors.

Parameters
AVector argument
BVector argument
Return values
Anglein degrees
math-anglebetweenvectors.png

◆ AngleDelta()

float UBPUtilsMathLibrary::AngleDelta ( const float  A,
const float  B 
)
static

Returns the signed shortest distance between two angles.

Parameters
AThe source angle
BThe target angle
Returns
The signed shortest distance between the angles
math-float-angledelta.png

◆ ClampIntReflect()

void UBPUtilsMathLibrary::ClampIntReflect ( const int32  Value,
const int32  Min,
const int32  Max,
int32 &  Result,
bool &  Reflected 
)
static

Clamps an int to the specified range, reflecting overshoots back into the range.

Parameters
ValueValue to clamp
MinMinimum value
MaxMaximum value
Return values
ResultClamped and reflected integer
ReflectedTrue if the int needed reflecting
math-clampintreflected.png

◆ ClampZeroToOne()

float UBPUtilsMathLibrary::ClampZeroToOne ( const float  Value)
static

Compact shortcut to clamp a float to [0, 1].

Parameters
ValueFloat input
Return values
Angleremapped to [-180°, 180°]
misc-clamp0to1.png

◆ FindClosestPoint()

void UBPUtilsMathLibrary::FindClosestPoint ( const FVector  Point,
const TArray< FVector >  Points,
FVector &  Closest,
int32 &  ClosestIndex 
)
static

Finds the closest point in a set.

Parameters
PointPoint to check distance against
PointsPoints to check for closest
Return values
ClosestThe closest point
ClosestIndexIndex of the closest point
math-closestpoint.png

◆ FloatArrayAverage()

float UBPUtilsMathLibrary::FloatArrayAverage ( const TArray< float > &  Array)
static

Returns the average of an array of floats.

Parameters
ArrayThe array to get the average of
Returns
The average of the values in the array
math-float-arrayaverage.png

◆ FloatArraySum()

float UBPUtilsMathLibrary::FloatArraySum ( const TArray< float > &  Array)
static

Returns the sum of an array of floats.

Parameters
ArrayThe array to get the sum of
Returns
The sum of the values in the array
math-float-arraysum.png

◆ FloatAverage()

float UBPUtilsMathLibrary::FloatAverage ( const float  A,
const float  B 
)
static

Returns the average of two floats.

Parameters
AThe first value
BThe second value
Returns
The average of the two values
math-float-average.png

◆ IntArraySum()

int32 UBPUtilsMathLibrary::IntArraySum ( const TArray< int32 > &  Array)
static

Returns the sum of an array of ints.

Parameters
ArrayThe array to get the sum of
Returns
The sum of the values in the array
math-int-arraysum.png

◆ IsPointInBox2D()

bool UBPUtilsMathLibrary::IsPointInBox2D ( const FVector2D  Point,
const FBox2D  Box 
)
static

Returns whether a point is inside the given box.

Parameters
PointThe point to test
BoxThe bounds to test for
Returns
true if the point is inside the bounds of the box
math-pointinbox.png

◆ MapAngleTo180()

float UBPUtilsMathLibrary::MapAngleTo180 ( const float  Value)
static

Remaps an angle to [-180°, 180°].

Parameters
ValueFloat input
Return values
Angleremapped to [-180°, 180°]
math-remapto180.png

◆ SystemRand()

int32 UBPUtilsMathLibrary::SystemRand ( )
static

Returns a random integer using the system rand() function.

Returns
Random value
math-sysrand.png