Module |
|
Header |
/Engine/Source/Runtime/Core/Public/Math/UnrealMathUtility.h |
Include |
#include "Math/UnrealMathUtility.h" |
struct FMath : public FMicrosoftPlatformMathBase
Structure for all math helper functions, inherits from platform math to pick up platform-specific implementations Check GenericPlatformMath.h for additional math functions
Name | Description | ||
---|---|---|---|
|
ApplyScaleToFloat ( |
Handy to apply scaling in the editor |
|
|
BiLerp |
Performs a linear interpolation between two values, Alpha ranges from 0-1 |
|
|
T |
BiLerp ( |
Performs a 2D linear interpolation between four values values, FracX, FracY ranges from 0-1 |
|
CartesianToPolar ( |
Converts given Cartesian coordinate pair to Polar coordinate system. |
|
|
CartesianToPolar |
Converts given Cartesian coordinate pair to Polar coordinate system. |
|
|
CInterpTo ( |
Interpolate Linear Color from Current to Target. |
|
|
T |
Clamp ( |
Clamps X to be between Min and Max, inclusive |
|
float |
ClampAngle ( |
Clamps an arbitrary angle to be between the given angles. Will clamp to nearest boundary. |
|
ClosestPointOnInfiniteLine |
Find the point on the infinite line between two points (LineStart, LineEnd) which is closest to Point |
|
|
ClosestPointOnLine |
Find the point on the line segment from LineStart to LineEnd which is closest to Point |
|
|
ClosestPointOnSegment |
Returns closest point on a segment to a given point. |
|
|
ClosestPointOnSegment2D |
FVector2D version of ClosestPointOnSegment. |
|
|
ClosestPointOnTetrahedronToPoint |
Returns closest point on a tetrahedron to a point. |
|
|
ClosestPointOnTriangleToPoint |
Returns closest point on a triangle to a point. |
|
|
ComputeBaryCentric2D |
Computes the barycentric coordinates for a given point in a triangle |
|
|
ComputeBaryCentric3D |
Computes the barycentric coordinates for a given point on a tetrahedron (3D) |
|
|
ComputeBoundingSphereForCone |
Computes minimal bounding sphere encompassing given cone |
|
|
ComputeProjectedSphereScissorRect |
InOutScissorRect should be set to View.ViewRect before the call |
|
|
U |
CubicCRSplineInterp ( |
Cubic Catmull-Rom Spline interpolation. |
|
U |
CubicCRSplineInterpSafe ( |
Same as CubicCRSplineInterp but with additional saftey checks. If the checks fail P1 is returned. |
|
T |
CubicInterp ( |
Performs a cubic interpolation |
|
CubicInterp |
In the case of quaternions, we use a bezier like approach. T - Actual 'control' orientations. |
|
|
T |
CubicInterpDerivative ( |
Performs a first derivative cubic interpolation |
|
T |
CubicInterpSecondDerivative ( |
Performs a second derivative cubic interpolation |
|
auto |
DegreesToRadians ( |
Converts degrees to radians. |
|
T |
DivideAndRoundDown ( |
Divides two integers and rounds down |
|
T |
DivideAndRoundNearest ( |
Divides two integers and rounds to nearest |
|
T |
DivideAndRoundUp ( |
Divides two integers and rounds up |
|
float |
DynamicWeightedMovingAverage ( |
Calculates the new value in a weighted moving average series using the previous value and a weight range. |
|
Eval ( |
Evaluates a numerical equation. |
|
|
ExtractBoolFromBitfield |
Get a bit in memory created from bitflags (uint32 Value:1), used for EngineShowFlags, TestBitFieldFunctions() tests the implementation |
|
|
float |
FastAsin ( |
Computes the ASin of a scalar value. |
|
float |
FindDeltaAngleDegrees ( |
Find the smallest angle between two headings (in degrees) |
|
float |
FindDeltaAngleRadians ( |
Find the smallest angle between two headings (in radians) |
|
float |
FInterpConstantTo ( |
Interpolate float from Current to Target with constant step |
|
float |
FInterpTo ( |
Interpolate float from Current to Target. |
|
float |
FixedTurn ( |
Returns a new rotation component value |
|
IntegralType |
Floor ( |
Converts an integral type to a nearest less or equal integer. |
|
float |
Floor ( |
Converts a float to a nearest less or equal integer. |
|
double |
Floor ( |
Converts a double to a nearest less or equal integer. |
|
FormatIntToHumanReadable ( |
Formats an integer value into a human readable string (i.e. 12345 becomes "12,345") |
|
|
float |
FRandRange ( |
Util to generate a random number in a range. |
|
GetAzimuthAndElevation |
Returns Azimuth and Elevation of vector 'Direction' in coordinate system O(AxisX,AxisY,AxisZ). |
|
|
GetBaryCentric2D |
Computes the barycentric coordinates for a given point in a triangle - simpler version |
|
|
GetDistanceWithinConeSegment |
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) |
|
|
GetDotDistance |
Calculates the dotted distance of vector 'Direction' to coordinate system O(AxisX,AxisY,AxisZ). |
|
|
T |
GetMappedRangeValueClamped |
|
|
float |
GetMappedRangeValueClamped |
For the given Value clamped to the [Input:Range] inclusive, returns the corresponding percentage in [Output:Range] Inclusive. |
|
float |
GetMappedRangeValueUnclamped |
Transform the given Value relative to the input range to the Output Range. |
|
GetRangePct ( |
Calculates the percentage along a line from MinValue to MaxValue that Value is. |
|
|
double |
GetRangePct ( |
|
|
float |
GetRangePct ( |
Same as above, but taking a 2d vector as the range. |
|
T |
GetRangeValue ( |
|
|
float |
GetRangeValue ( |
Basically a Vector2d version of Lerp. |
|
GetReflectionVector |
Given a direction vector and a surface normal, returns the vector reflected across the surface normal. |
|
|
float |
GetTForSegmentPlaneIntersect |
Returns the time (t) of the intersection of the passed segment and a plane (could be <0 or >1) |
|
GreatestCommonDivisor |
Use the Euclidean method to find the GCD. |
|
|
T |
GridSnap ( |
Snaps a value to the nearest grid multiple |
|
T |
InterpCircularIn ( |
Interpolation between A and B, applying a circular in function. |
|
T |
InterpCircularInOut ( |
Interpolation between A and B, applying a circular in/out function. |
|
T |
InterpCircularOut ( |
Interpolation between A and B, applying a circular out function. |
|
T |
InterpEaseIn ( |
Interpolate between A and B, applying an ease in function. Exp controls the degree of the curve. |
|
T |
InterpEaseInOut ( |
Interpolate between A and B, applying an ease in/out function. |
|
T |
InterpEaseOut ( |
Interpolate between A and B, applying an ease out function. Exp controls the degree of the curve. |
|
T |
InterpExpoIn ( |
Interpolation between A and B, applying an exponential in function. |
|
T |
InterpExpoInOut ( |
Interpolation between A and B, applying an exponential in/out function. |
|
T |
InterpExpoOut ( |
Interpolation between A and B, applying an exponential out function. |
|
T |
InterpSinIn ( |
Interpolation between A and B, applying a sinusoidal in function. |
|
T |
InterpSinInOut ( |
Interpolation between A and B, applying a sinusoidal in/out function. |
|
T |
InterpSinOut ( |
Interpolation between A and B, applying a sinusoidal out function. |
|
T |
InterpStep ( |
Interpolation between A and B, applying a step function. |
|
IntersectPlanes2 |
Compute intersection point and direction of line joining two planes. |
|
|
IntersectPlanes3 |
Compute intersection point of three planes. Return 1 if valid, 0 if infinite. |
|
|
IsNearlyEqual ( |
Checks if two floating point numbers are nearly equal. |
|
|
IsNearlyEqual ( |
Checks if two floating point numbers are nearly equal. |
|
|
IsNearlyEqualByULP ( |
Check if two floating point numbers are nearly equal to within specific number of units of last place (ULP). |
|
|
IsNearlyEqualByULP ( |
Check if two floating point numbers are nearly equal to within specific number of units of last place (ULP). |
|
|
IsNearlyZero ( |
Checks if a floating point number is nearly zero. |
|
|
IsNearlyZero ( |
Checks if a floating point number is nearly zero. |
|
|
IsPowerOfTwo ( |
Checks whether a number is a power of two. |
|
|
IsWithin ( |
Checks if value is within a range, exclusive on MaxValue) |
|
|
IsWithinInclusive ( |
Checks if value is within a range, inclusive on MaxValue) |
|
|
LeastCommonMultiplier |
LCM = a/gcd * b a and b are the number we want to find the lcm |
|
|
T |
Lerp ( |
Performs a linear interpolation between two values, Alpha ranges from 0-1 |
|
Lerp |
Rotator specific interpolation. |
|
|
Lerp |
FMath inline functions |
|
|
VectorRegist... |
Lerp ( |
Specialization of Lerp template that works with vector registers. |
|
LerpRange |
Performs a linear interpolation between two values, Alpha ranges from 0-1 |
|
|
T |
LerpStable ( |
Performs a linear interpolation between two values, Alpha ranges from 0-1. |
|
T |
LerpStable ( |
Performs a linear interpolation between two values, Alpha ranges from 0-1. |
|
LineBoxIntersection |
Determines whether a line intersects a box. |
|
|
LineBoxIntersection |
Determines whether a line intersects a box. |
|
|
LineExtentBoxIntersection |
Swept-Box vs Box test |
|
|
LinePlaneIntersection |
Find the intersection of a line and an offset plane. |
|
|
LinePlaneIntersection |
Find the intersection of a line and a plane. |
|
|
LineSphereIntersection |
Determines whether a line intersects a sphere. |
|
|
float |
Log2 ( |
Computes the base 2 logarithm of the specified value |
|
float |
MakePulsatingValue ( |
Simple function to create a pulsating scalar value |
|
T |
Max3 ( |
Returns highest of 3 values |
|
MemoryTest |
Tests a memory region to see that it's working properly. |
|
|
T |
Min3 ( |
Returns lowest of 3 values |
|
float |
PerlinNoise1D ( |
Generates a 1D Perlin noise from the given value. |
|
float |
PerlinNoise2D ( |
Generates a 1D Perlin noise sample at the given location. |
|
float |
PerlinNoise3D ( |
Generates a 3D Perlin noise sample at the given location. |
|
PlaneAABBIntersection |
Determine if a plane and an AABB intersect |
|
|
PlaneAABBRelativePosition |
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 |
|
|
PointBoxIntersection |
Determines whether a point is inside a box. |
|
|
float |
PointDistToLine |
Calculates the distance of a given Point in world space to a given line, defined by the vector couple (Origin, Direction). |
|
float |
PointDistToLine |
Calculates the distance of a given Point in world space to a given line, defined by the vector couple (Origin, Direction). |
|
float |
PointDistToSegment |
Returns distance from a point to the closest point on a segment. |
|
float |
PointDistToSegmentSquared |
Returns square of the distance from a point to the closest point on a segment. |
|
PointsAreCoplanar |
Determines whether a given set of points are coplanar, with a tolerance. |
|
|
PolarToCartesian ( |
Converts given Polar coordinate pair to Cartesian coordinate system. |
|
|
PolarToCartesian |
Converts given Polar coordinate pair to Cartesian coordinate system. |
|
|
QInterpConstantTo |
Interpolate quaternion from Current to Target with constant step (in radians) |
|
|
QInterpTo |
Interpolate quaternion from Current to Target. |
|
|
Quantize8SignedByte ( |
||
|
Quantize8UnsignedByte ( |
||
|
auto |
RadiansToDegrees ( |
Converts radians to degrees. |
|
RandBool() |
Util to generate a random boolean. |
|
|
RandHelper ( |
Helper function for rand implementations. Returns a random number in [0..A) |
|
|
RandHelper64 ( |
||
|
RandPointInBox ( |
Returns a random point within the passed in bounding box |
|
|
RandPointInCircle ( |
Returns a random point, uniformly distributed, within the specified radius |
|
|
float |
RandRange ( |
Util to generate a random number in a range. |
|
RandRange |
||
|
RandRange |
Helper function for rand implementations. Returns a random number >= Min and <= Max |
|
|
RayPlaneIntersection |
Find the intersection of a ray and a plane. |
|
|
RInterpConstantTo |
Interpolate rotator from Current to Target with constant step |
|
|
RInterpTo |
Interpolate rotator from Current to Target. |
|
|
double |
RoundFromZero ( |
|
|
float |
RoundFromZero ( |
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 |
|
double |
RoundHalfFromZero ( |
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 |
|
float |
RoundHalfFromZero ( |
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 |
|
double |
RoundHalfToEven ( |
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 |
|
float |
RoundHalfToEven ( |
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 |
|
float |
RoundHalfToZero ( |
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 |
|
double |
RoundHalfToZero ( |
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 |
|
float |
RoundToNegativeInfinity ( |
Converts a floating point number to an integer which is more negative: 0.1 becomes 0, -0.1 becomes -1 |
|
double |
RoundToNegativeInfinity ( |
|
|
float |
RoundToPositiveInfinity ( |
Converts a floating point number to an integer which is more positive: 0.1 becomes 1, -0.1 becomes 0 |
|
double |
RoundToPositiveInfinity ( |
|
|
float |
RoundToZero ( |
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 |
|
double |
RoundToZero ( |
|
|
SegmentDistToSegment |
Find closest points between 2 segments. |
|
|
SegmentDistToSegmentSafe |
Find closest points between 2 segments. |
|
|
SegmentIntersection2D |
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. |
|
|
SegmentPlaneIntersection |
Returns true if there is an intersection between the segment specified by StartPoint and Endpoint, and the plane on which polygon Plane lies. |
|
|
SegmentTriangleIntersection |
Returns true if there is an intersection between the segment specified by StartPoint and Endpoint, and the Triangle defined by A, B and C. |
|
|
SetBoolInBitField |
Set a bit in memory created from bitflags (uint32 Value:1), used for EngineShowFlags, TestBitFieldFunctions() tests the implementation |
|
|
SinCos ( |
Computes the sine and cosine of a scalar value. |
|
|
float |
SmoothStep ( |
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. |
|
SphereAABBIntersection |
Performs a sphere vs box intersection test using Arvo's algorithm: |
|
|
SphereAABBIntersection |
Converts a sphere into a point plus radius squared for the test above |
|
|
SphereConeIntersection |
Assumes the cone tip is at 0,0,0 (means the SphereCenter is relative to the cone tip) |
|
|
SphereDistToLine |
Find closest point on a Sphere to a Line. |
|
|
T |
Square ( |
Multiples value by itself |
|
double |
TruncateToHalfIfClose ( |
Truncates a floating point number to half if closer than the given tolerance. |
|
float |
TruncateToHalfIfClose ( |
Truncates a floating point number to half if closer than the given tolerance. |
|
float |
UnwindDegrees ( |
Utility to ensure angle is between +/- 180 degrees by unwinding. |
|
float |
UnwindRadians ( |
Given a heading which may be outside the +/- PI range, 'unwind' it back into that range. |
|
Vector2DInterpConstantTo |
Interpolate vector2D from Current to Target with constant step |
|
|
Vector2DInterpTo |
Interpolate vector2D from Current to Target. |
|
|
VInterpConstantTo |
Interpolate vector from Current to Target with constant step |
|
|
VInterpNormalRotationTo |
Interpolate a normal vector Current to Target, by interpolating the angle between those vectors with constant step. |
|
|
VInterpTo |
Interpolate vector from Current to Target. |
|
|
VRand() |
Return a uniformly distributed random unit length vector = point on the unit sphere surface. |
|
|
VRandCone ( |
This is a version of VRandCone that handles "squished" cones, i.e. with different angle limits in the Y and Z axes. |
|
|
VRandCone ( |
Returns a random unit vector, uniformly distributed, within the specified cone ConeHalfAngleRad is the half-angle of cone, in radians. |
|
|
float |
WeightedMovingAverage ( |
Calculates the new value in a weighted moving average series using the previous value and the weight |
|
WindRelativeAnglesDegrees ( |
Given two angles in degrees, 'wind' the rotation in Angle1 so that it avoids >180 degree flips. |
|
|
T |
Wrap ( |
Wraps X to be between Min and Max, inclusive |
Name |
Description |
---|---|
BitFlag |
32 bit values where BitFlag[x] == (1< |
Name | Description | ||
---|---|---|---|
|
float |
FindDeltaAngle ( |
Please use FindDeltaAngleRadians(float A1, float A2) instead of FindDeltaAngle(float A1, float A2). |