engine
 
载入中...
搜索中...
未找到
静态 Public 成员函数 | 静态 Public 属性 | 所有成员列表
FMath结构体 参考

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

#include <UnrealMathUtility.h>

+ 类 FMath 继承关系图:

静态 Public 成员函数

static CORE_API void ApplyScaleToFloat (float &Dst, const FVector &DeltaScale, float Magnitude=1.0f)
 Handy to apply scaling in the editor 更多...
 
template<class T , class U >
static FORCEINLINE_DEBUGGABLE T BiLerp (const T &P00, const T &P10, const T &P01, const T &P11, const U &FracX, const U &FracY)
 Performs a 2D linear interpolation between four values values, FracX, FracY ranges from 0-1
 
static FORCEINLINE void CartesianToPolar (const float X, const float Y, float &OutRad, float &OutAng)
 Converts given Cartesian coordinate pair to Polar coordinate system.
 
static FORCEINLINE void CartesianToPolar (const FVector2D InCart, FVector2D &OutPolar)
 Converts given Cartesian coordinate pair to Polar coordinate system.
 
static CORE_API FLinearColor CInterpTo (const FLinearColor &Current, const FLinearColor &Target, float DeltaTime, float InterpSpeed)
 Interpolate Linear Color from Current to Target. 更多...
 
template<class T >
static UE_NODISCARD FORCEINLINE T Clamp (const T X, const T Min, const T Max)
 Clamps X to be between Min and Max, inclusive
 
static CORE_API float ClampAngle (float AngleDegrees, float MinAngleDegrees, float MaxAngleDegrees)
 Clamps an arbitrary angle to be between the given angles. 更多...
 
static CORE_API FVector ClosestPointOnInfiniteLine (const FVector &LineStart, const FVector &LineEnd, const FVector &Point)
 Find the point on the infinite line between two points (LineStart, LineEnd) which is closest to Point
 
static CORE_API FVector ClosestPointOnLine (const FVector &LineStart, const FVector &LineEnd, const FVector &Point)
 Find the point on the line segment from LineStart to LineEnd which is closest to Point
 
static CORE_API FVector ClosestPointOnSegment (const FVector &Point, const FVector &StartPoint, const FVector &EndPoint)
 Returns closest point on a segment to a given point. 更多...
 
static CORE_API FVector2D ClosestPointOnSegment2D (const FVector2D &Point, const FVector2D &StartPoint, const FVector2D &EndPoint)
 FVector2D version of ClosestPointOnSegment. 更多...
 
static CORE_API FVector ClosestPointOnTetrahedronToPoint (const FVector &Point, const FVector &A, const FVector &B, const FVector &C, const FVector &D)
 Returns closest point on a tetrahedron to a point. 更多...
 
static CORE_API FVector ClosestPointOnTriangleToPoint (const FVector &Point, const FVector &A, const FVector &B, const FVector &C)
 Returns closest point on a triangle to a point. 更多...
 
static CORE_API FVector ComputeBaryCentric2D (const FVector &Point, const FVector &A, const FVector &B, const FVector &C)
 Computes the barycentric coordinates for a given point in a triangle 更多...
 
static CORE_API FVector4 ComputeBaryCentric3D (const FVector &Point, const FVector &A, const FVector &B, const FVector &C, const FVector &D)
 Computes the barycentric coordinates for a given point on a tetrahedron (3D) 更多...
 
static FSphere ComputeBoundingSphereForCone (FVector const &ConeOrigin, FVector const &ConeDirection, float ConeRadius, float CosConeAngle, float SinConeAngle)
 Computes minimal bounding sphere encompassing given cone
 
template<class U >
static FQuat CubicInterp (const FQuat &P0, const FQuat &T0, const FQuat &P1, const FQuat &T1, const U &A)
 In the case of quaternions, we use a bezier like approach. 更多...
 
template<class T , class U >
static FORCEINLINE_DEBUGGABLE T CubicInterp (const T &P0, const T &T0, const T &P1, const T &T1, const U &A)
 Performs a cubic interpolation 更多...
 
template<class T , class U >
static FORCEINLINE_DEBUGGABLE T CubicInterpDerivative (const T &P0, const T &T0, const T &P1, const T &T1, const U &A)
 Performs a first derivative cubic interpolation 更多...
 
template<class T , class U >
static FORCEINLINE_DEBUGGABLE T CubicInterpSecondDerivative (const T &P0, const T &T0, const T &P1, const T &T1, const U &A)
 Performs a second derivative cubic interpolation 更多...
 
template<class T >
static FORCEINLINE auto DegreesToRadians (T const &DegVal) -> decltype(DegVal *(PI/180.f))
 Converts degrees to radians. 更多...
 
template<class T >
static FORCEINLINE T DivideAndRoundDown (T Dividend, T Divisor)
 Divides two integers and rounds down
 
template<class T >
static FORCEINLINE T DivideAndRoundNearest (T Dividend, T Divisor)
 Divides two integers and rounds to nearest
 
template<class T >
static FORCEINLINE T DivideAndRoundUp (T Dividend, T Divisor)
 Divides two integers and rounds up
 
static CORE_API float DynamicWeightedMovingAverage (float CurrentSample, float PreviousSample, float MaxDistance, float MinWeight, float MaxWeight)
 Calculates the new value in a weighted moving average series using the previous value and a weight range. 更多...
 
static CORE_API bool Eval (FString Str, float &OutValue)
 Evaluates a numerical equation. 更多...
 
static bool ExtractBoolFromBitfield (uint8 *Ptr, uint32 Index)
 Get a bit in memory created from bitflags (uint32 Value:1), used for EngineShowFlags, TestBitFieldFunctions() tests the implementation
 
static FORCEINLINE float FastAsin (float Value)
 Computes the ASin of a scalar value. 更多...
 
static float FindDeltaAngleDegrees (float A1, float A2)
 Find the smallest angle between two headings (in degrees)
 
static float FindDeltaAngleRadians (float A1, float A2)
 Find the smallest angle between two headings (in radians)
 
static CORE_API float FInterpConstantTo (float Current, float Target, float DeltaTime, float InterpSpeed)
 Interpolate float from Current to Target with constant step
 
static CORE_API float FInterpTo (float Current, float Target, float DeltaTime, float InterpSpeed)
 Interpolate float from Current to Target. 更多...
 
static CORE_API float FixedTurn (float InCurrent, float InDesired, float InDeltaRate)
 Returns a new rotation component value 更多...
 
static FORCEINLINE double Floor (double F)
 Converts a double to a nearest less or equal integer.
 
static FORCEINLINE float Floor (float F)
 Converts a float to a nearest less or equal integer.
 
template<typename IntegralType , typename TEnableIf< TIsIntegral< IntegralType >::Value >::Type * = nullptr>
static FORCEINLINE IntegralType Floor (IntegralType I)
 Converts an integral type to a nearest less or equal integer. 更多...
 
static CORE_API FString FormatIntToHumanReadable (int32 Val)
 Formats an integer value into a human readable string (i.e. 更多...
 
static FORCEINLINE float FRandRange (float InMin, float InMax)
 Util to generate a random number in a range.
 
static CORE_API FVector2D GetAzimuthAndElevation (const FVector &Direction, const FVector &AxisX, const FVector &AxisY, const FVector &AxisZ)
 Returns Azimuth and Elevation of vector 'Direction' in coordinate system O(AxisX,AxisY,AxisZ). 更多...
 
static CORE_API FVector GetBaryCentric2D (const FVector &Point, const FVector &A, const FVector &B, const FVector &C)
 Computes the barycentric coordinates for a given point in a triangle - simpler version 更多...
 
static CORE_API bool GetDistanceWithinConeSegment (FVector Point, FVector ConeStartPoint, FVector ConeLine, float RadiusAtStart, float RadiusAtEnd, float &PercentageOut)
 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) 更多...
 
static CORE_API bool GetDotDistance (FVector2D &OutDotDist, const FVector &Direction, const FVector &AxisX, const FVector &AxisY, const FVector &AxisZ)
 Calculates the dotted distance of vector 'Direction' to coordinate system O(AxisX,AxisY,AxisZ). 更多...
 
static FORCEINLINE float GetMappedRangeValueClamped (const FVector2D &InputRange, const FVector2D &OutputRange, const float Value)
 For the given Value clamped to the [Input:Range] inclusive, returns the corresponding percentage in [Output:Range] Inclusive.
 
static FORCEINLINE float GetMappedRangeValueUnclamped (const FVector2D &InputRange, const FVector2D &OutputRange, const float Value)
 Transform the given Value relative to the input range to the Output Range.
 
static float GetRangePct (FVector2D const &Range, float Value)
 Same as above, but taking a 2d vector as the range.
 
template<typename T >
static FORCEINLINE TEnableIf< TIsFloatingPoint< T >::Value, T >::Type GetRangePct (T MinValue, T MaxValue, T Value)
 Calculates the percentage along a line from MinValue to MaxValue that Value is.
 
static float GetRangeValue (FVector2D const &Range, float Pct)
 Basically a Vector2d version of Lerp.
 
static CORE_API FVector GetReflectionVector (const FVector &Direction, const FVector &SurfaceNormal)
 Given a direction vector and a surface normal, returns the vector reflected across the surface normal. 更多...
 
static CORE_API float GetTForSegmentPlaneIntersect (const FVector &StartPoint, const FVector &EndPoint, const FPlane &Plane)
 returns the time (t) of the intersection of the passed segment and a plane (could be <0 or >1) 更多...
 
template<class T >
static FORCEINLINE T GridSnap (T Location, T Grid)
 Snaps a value to the nearest grid multiple
 
template<class T >
static FORCEINLINE_DEBUGGABLE T InterpCircularIn (const T &A, const T &B, float Alpha)
 Interpolation between A and B, applying a circular in function.
 
template<class T >
static FORCEINLINE_DEBUGGABLE T InterpCircularInOut (const T &A, const T &B, float Alpha)
 Interpolation between A and B, applying a circular in/out function.
 
template<class T >
static FORCEINLINE_DEBUGGABLE T InterpCircularOut (const T &A, const T &B, float Alpha)
 Interpolation between A and B, applying a circular out function.
 
template<class T >
static FORCEINLINE_DEBUGGABLE T InterpEaseIn (const T &A, const T &B, float Alpha, float Exp)
 Interpolate between A and B, applying an ease in function. 更多...
 
template<class T >
static FORCEINLINE_DEBUGGABLE T InterpEaseInOut (const T &A, const T &B, float Alpha, float Exp)
 Interpolate between A and B, applying an ease in/out function. 更多...
 
template<class T >
static FORCEINLINE_DEBUGGABLE T InterpEaseOut (const T &A, const T &B, float Alpha, float Exp)
 Interpolate between A and B, applying an ease out function. 更多...
 
template<class T >
static FORCEINLINE_DEBUGGABLE T InterpExpoIn (const T &A, const T &B, float Alpha)
 Interpolation between A and B, applying an exponential in function.
 
template<class T >
static FORCEINLINE_DEBUGGABLE T InterpExpoInOut (const T &A, const T &B, float Alpha)
 Interpolation between A and B, applying an exponential in/out function.
 
template<class T >
static FORCEINLINE_DEBUGGABLE T InterpExpoOut (const T &A, const T &B, float Alpha)
 Interpolation between A and B, applying an exponential out function.
 
template<class T >
static FORCEINLINE_DEBUGGABLE T InterpSinIn (const T &A, const T &B, float Alpha)
 Interpolation between A and B, applying a sinusoidal in function.
 
template<class T >
static FORCEINLINE_DEBUGGABLE T InterpSinInOut (const T &A, const T &B, float Alpha)
 Interpolation between A and B, applying a sinusoidal in/out function.
 
template<class T >
static FORCEINLINE_DEBUGGABLE T InterpSinOut (const T &A, const T &B, float Alpha)
 Interpolation between A and B, applying a sinusoidal out function.
 
template<class T >
static FORCEINLINE_DEBUGGABLE T InterpStep (const T &A, const T &B, float Alpha, int32 Steps)
 Interpolation between A and B, applying a step function.
 
static bool IntersectPlanes2 (FVector &I, FVector &D, const FPlane &P1, const FPlane &P2)
 Compute intersection point and direction of line joining two planes. 更多...
 
static bool IntersectPlanes3 (FVector &I, const FPlane &P1, const FPlane &P2, const FPlane &P3)
 Compute intersection point of three planes. 更多...
 
static FORCEINLINE bool IsNearlyEqual (double A, double B, double ErrorTolerance=SMALL_NUMBER)
 Checks if two floating point numbers are nearly equal. 更多...
 
static FORCEINLINE bool IsNearlyEqual (float A, float B, float ErrorTolerance=SMALL_NUMBER)
 Checks if two floating point numbers are nearly equal. 更多...
 
static FORCEINLINE bool IsNearlyEqualByULP (double A, double B, int32 MaxUlps=4)
 Check if two floating point numbers are nearly equal to within specific number of units of last place (ULP). 更多...
 
static FORCEINLINE bool IsNearlyEqualByULP (float A, float B, int32 MaxUlps=4)
 Check if two floating point numbers are nearly equal to within specific number of units of last place (ULP). 更多...
 
static FORCEINLINE bool IsNearlyZero (double Value, double ErrorTolerance=SMALL_NUMBER)
 Checks if a floating point number is nearly zero. 更多...
 
static FORCEINLINE bool IsNearlyZero (float Value, float ErrorTolerance=SMALL_NUMBER)
 Checks if a floating point number is nearly zero. 更多...
 
template<typename T >
static FORCEINLINE bool IsPowerOfTwo (T Value)
 Checks whether a number is a power of two. 更多...
 
template<class U >
static FORCEINLINE bool IsWithin (const U &TestValue, const U &MinValue, const U &MaxValue)
 Checks if value is within a range, exclusive on MaxValue)
 
template<class U >
static FORCEINLINE bool IsWithinInclusive (const U &TestValue, const U &MinValue, const U &MaxValue)
 Checks if value is within a range, inclusive on MaxValue)
 
template<class T , class U >
static FORCEINLINE_DEBUGGABLE T Lerp (const T &A, const T &B, const U &Alpha)
 Performs a linear interpolation between two values, Alpha ranges from 0-1
 
template<class T >
static FORCEINLINE_DEBUGGABLE T LerpStable (const T &A, const T &B, double Alpha)
 Performs a linear interpolation between two values, Alpha ranges from 0-1. 更多...
 
template<class T >
static FORCEINLINE_DEBUGGABLE T LerpStable (const T &A, const T &B, float Alpha)
 Performs a linear interpolation between two values, Alpha ranges from 0-1. 更多...
 
static bool LineBoxIntersection (const FBox &Box, const FVector &Start, const FVector &End, const FVector &Direction)
 Determines whether a line intersects a box.
 
static bool LineBoxIntersection (const FBox &Box, const FVector &Start, const FVector &End, const FVector &Direction, const FVector &OneOverDirection)
 Determines whether a line intersects a box. 更多...
 
static FVector LinePlaneIntersection (const FVector &Point1, const FVector &Point2, const FPlane &Plane)
 Find the intersection of a line and a plane. 更多...
 
static FVector LinePlaneIntersection (const FVector &Point1, const FVector &Point2, const FVector &PlaneOrigin, const FVector &PlaneNormal)
 Find the intersection of a line and an offset plane. 更多...
 
static bool LineSphereIntersection (const FVector &Start, const FVector &Dir, float Length, const FVector &Origin, float Radius)
 Determines whether a line intersects a sphere.
 
static FORCEINLINE float Log2 (float Value)
 Computes the base 2 logarithm of the specified value 更多...
 
static float MakePulsatingValue (const double InCurrentTime, const float InPulsesPerSecond, const float InPhase=0.0f)
 Simple function to create a pulsating scalar value 更多...
 
template<class T >
static FORCEINLINE T Max3 (const T A, const T B, const T C)
 Returns highest of 3 values
 
static CORE_API bool MemoryTest (void *BaseAddress, uint32 NumBytes)
 Tests a memory region to see that it's working properly. 更多...
 
template<class T >
static FORCEINLINE T Min3 (const T A, const T B, const T C)
 Returns lowest of 3 values
 
static CORE_API float PerlinNoise1D (float Value)
 Generates a 1D Perlin noise from the given value. 更多...
 
static CORE_API float PerlinNoise2D (const FVector2D &Location)
 Generates a 1D Perlin noise sample at the given location. 更多...
 
static CORE_API float PerlinNoise3D (const FVector &Location)
 Generates a 3D Perlin noise sample at the given location. 更多...
 
static CORE_API bool PlaneAABBIntersection (const FPlane &P, const FBox &AABB)
 Determine if a plane and an AABB intersect 更多...
 
static CORE_API int32 PlaneAABBRelativePosition (const FPlane &P, const FBox &AABB)
 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 更多...
 
static bool PointBoxIntersection (const FVector &Point, const FBox &Box)
 Determines whether a point is inside a box.
 
static CORE_API float PointDistToLine (const FVector &Point, const FVector &Direction, const FVector &Origin, FVector &OutClosestPoint)
 Calculates the distance of a given Point in world space to a given line, defined by the vector couple (Origin, Direction). 更多...
 
static CORE_API float PointDistToSegment (const FVector &Point, const FVector &StartPoint, const FVector &EndPoint)
 Returns distance from a point to the closest point on a segment. 更多...
 
static CORE_API float PointDistToSegmentSquared (const FVector &Point, const FVector &StartPoint, const FVector &EndPoint)
 Returns square of the distance from a point to the closest point on a segment. 更多...
 
static CORE_API bool PointsAreCoplanar (const TArray< FVector > &Points, const float Tolerance=0.1f)
 Determines whether a given set of points are coplanar, with a tolerance. 更多...
 
static FORCEINLINE void PolarToCartesian (const float Rad, const float Ang, float &OutX, float &OutY)
 Converts given Polar coordinate pair to Cartesian coordinate system.
 
static FORCEINLINE void PolarToCartesian (const FVector2D InPolar, FVector2D &OutCart)
 Converts given Polar coordinate pair to Cartesian coordinate system.
 
static CORE_API FQuat QInterpConstantTo (const FQuat &Current, const FQuat &Target, float DeltaTime, float InterpSpeed)
 Interpolate quaternion from Current to Target with constant step (in radians)
 
static CORE_API FQuat QInterpTo (const FQuat &Current, const FQuat &Target, float DeltaTime, float InterpSpeed)
 Interpolate quaternion from Current to Target. 更多...
 
template<class T >
static FORCEINLINE auto RadiansToDegrees (T const &RadVal) -> decltype(RadVal *(180.f/PI))
 Converts radians to degrees. 更多...
 
static FORCEINLINE bool RandBool ()
 Util to generate a random boolean.
 
static FORCEINLINE int32 RandHelper (int32 A)
 Helper function for rand implementations. 更多...
 
static CORE_API FVector RandPointInBox (const FBox &Box)
 Returns a random point within the passed in bounding box
 
static CORE_API FVector2D RandPointInCircle (float CircleRadius)
 Returns a random point, uniformly distributed, within the specified radius
 
static FORCEINLINE float RandRange (float InMin, float InMax)
 Util to generate a random number in a range. 更多...
 
static FORCEINLINE int32 RandRange (int32 Min, int32 Max)
 Helper function for rand implementations. 更多...
 
static FVector RayPlaneIntersection (const FVector &RayOrigin, const FVector &RayDirection, const FPlane &Plane)
 Find the intersection of a ray and a plane. 更多...
 
static CORE_API FRotator RInterpConstantTo (const FRotator &Current, const FRotator &Target, float DeltaTime, float InterpSpeed)
 Interpolate rotator from Current to Target with constant step
 
static CORE_API FRotator RInterpTo (const FRotator &Current, const FRotator &Target, float DeltaTime, float InterpSpeed)
 Interpolate rotator from Current to Target. 更多...
 
static FORCEINLINE float RoundFromZero (float F)
 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 更多...
 
static CORE_API float RoundHalfFromZero (float F)
 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 更多...
 
static CORE_API float RoundHalfToEven (float F)
 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 更多...
 
static CORE_API float RoundHalfToZero (float F)
 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 更多...
 
static FORCEINLINE float RoundToNegativeInfinity (float F)
 Converts a floating point number to an integer which is more negative: 0.1 becomes 0, -0.1 becomes -1 更多...
 
static FORCEINLINE float RoundToPositiveInfinity (float F)
 Converts a floating point number to an integer which is more positive: 0.1 becomes 1, -0.1 becomes 0 更多...
 
static FORCEINLINE float RoundToZero (float F)
 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 更多...
 
static CORE_API void SegmentDistToSegment (FVector A1, FVector B1, FVector A2, FVector B2, FVector &OutP1, FVector &OutP2)
 Find closest points between 2 segments. 更多...
 
static CORE_API void SegmentDistToSegmentSafe (FVector A1, FVector B1, FVector A2, FVector B2, FVector &OutP1, FVector &OutP2)
 Find closest points between 2 segments. 更多...
 
static CORE_API bool SegmentIntersection2D (const FVector &SegmentStartA, const FVector &SegmentEndA, const FVector &SegmentStartB, const FVector &SegmentEndB, FVector &out_IntersectionPoint)
 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. 更多...
 
static CORE_API bool SegmentPlaneIntersection (const FVector &StartPoint, const FVector &EndPoint, const FPlane &Plane, FVector &out_IntersectionPoint)
 Returns true if there is an intersection between the segment specified by StartPoint and Endpoint, and the plane on which polygon Plane lies. 更多...
 
static CORE_API bool SegmentTriangleIntersection (const FVector &StartPoint, const FVector &EndPoint, const FVector &A, const FVector &B, const FVector &C, FVector &OutIntersectPoint, FVector &OutTriangleNormal)
 Returns true if there is an intersection between the segment specified by StartPoint and Endpoint, and the Triangle defined by A, B and C. 更多...
 
static void SetBoolInBitField (uint8 *Ptr, uint32 Index, bool bSet)
 Set a bit in memory created from bitflags (uint32 Value:1), used for EngineShowFlags, TestBitFieldFunctions() tests the implementation
 
static FORCEINLINE void SinCos (float *ScalarSin, float *ScalarCos, float Value)
 Computes the sine and cosine of a scalar value. 更多...
 
static float SmoothStep (float A, float B, float X)
 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. 更多...
 
static bool SphereAABBIntersection (const FSphere &Sphere, const FBox &AABB)
 Converts a sphere into a point plus radius squared for the test above
 
static bool SphereAABBIntersection (const FVector &SphereCenter, const float RadiusSquared, const FBox &AABB)
 Performs a sphere vs box intersection test using Arvo's algorithm: 更多...
 
static CORE_API bool SphereConeIntersection (const FVector &SphereCenter, float SphereRadius, const FVector &ConeAxis, float ConeAngleSin, float ConeAngleCos)
 Assumes the cone tip is at 0,0,0 (means the SphereCenter is relative to the cone tip) 更多...
 
static CORE_API void SphereDistToLine (FVector SphereOrigin, float SphereRadius, FVector LineOrigin, FVector LineDir, FVector &OutClosestPoint)
 Find closest point on a Sphere to a Line. 更多...
 
template<class T >
static FORCEINLINE T Square (const T A)
 Multiples value by itself
 
static CORE_API float TruncateToHalfIfClose (float F, float Tolerance=SMALL_NUMBER)
 Truncates a floating point number to half if closer than the given tolerance. 更多...
 
static float UnwindDegrees (float A)
 Utility to ensure angle is between +/- 180 degrees by unwinding.
 
static float UnwindRadians (float A)
 Given a heading which may be outside the +/- PI range, 'unwind' it back into that range.
 
static CORE_API FVector2D Vector2DInterpConstantTo (const FVector2D &Current, const FVector2D &Target, float DeltaTime, float InterpSpeed)
 Interpolate vector2D from Current to Target with constant step
 
static CORE_API FVector2D Vector2DInterpTo (const FVector2D &Current, const FVector2D &Target, float DeltaTime, float InterpSpeed)
 Interpolate vector2D from Current to Target. 更多...
 
static CORE_API FVector VInterpConstantTo (const FVector &Current, const FVector &Target, float DeltaTime, float InterpSpeed)
 Interpolate vector from Current to Target with constant step
 
static CORE_API FVector VInterpNormalRotationTo (const FVector &Current, const FVector &Target, float DeltaTime, float RotationSpeedDegrees)
 Interpolate a normal vector Current to Target, by interpolating the angle between those vectors with constant step.
 
static CORE_API FVector VInterpTo (const FVector &Current, const FVector &Target, float DeltaTime, float InterpSpeed)
 Interpolate vector from Current to Target. 更多...
 
static FVector VRand ()
 Return a uniformly distributed random unit length vector = point on the unit sphere surface.
 
static CORE_API FVector VRandCone (FVector const &Dir, float ConeHalfAngleRad)
 Returns a random unit vector, uniformly distributed, within the specified cone ConeHalfAngleRad is the half-angle of cone, in radians. 更多...
 
static CORE_API FVector VRandCone (FVector const &Dir, float HorizontalConeHalfAngleRad, float VerticalConeHalfAngleRad)
 This is a version of VRandCone that handles "squished" cones, i.e. 更多...
 
static CORE_API float WeightedMovingAverage (float CurrentSample, float PreviousSample, float Weight)
 Calculates the new value in a weighted moving average series using the previous value and the weight 更多...
 
static CORE_API void WindRelativeAnglesDegrees (float InAngle0, float &InOutAngle1)
 Given two angles in degrees, 'wind' the rotation in Angle1 so that it avoids >180 degree flips. 更多...
 
template<class T >
static FORCEINLINE T Wrap (const T X, const T Min, const T Max)
 Wraps X to be between Min and Max, inclusive
 
- 静态 Public 成员函数 继承自 FClangPlatformMath
static FORCEINLINE uint32 CountLeadingZeros (uint32 Value)
 Counts the number of leading zeros in the bit representation of the value 更多...
 
static FORCEINLINE uint64 CountLeadingZeros64 (uint64 Value)
 Counts the number of leading zeros in the bit representation of the value 更多...
 
static FORCEINLINE uint8 CountLeadingZeros8 (uint8 Value)
 Counts the number of leading zeros in the bit representation of the value 更多...
 
static FORCEINLINE uint32 CountTrailingZeros (uint32 Value)
 Counts the number of trailing zeros in the bit representation of the value 更多...
 
static FORCEINLINE uint64 CountTrailingZeros64 (uint64 Value)
 Counts the number of trailing zeros in the bit representation of the value 更多...
 
- 静态 Public 成员函数 继承自 FGenericPlatformMath
template<class T >
static CONSTEXPR FORCEINLINE T Abs (const T A)
 Computes absolute value in a generic way
 
static FORCEINLINE uint32 CeilLogTwo (uint32 Arg)
 Returns smallest N such that (1<<N)>=Arg. 更多...
 
static FORCEINLINE double CeilToDouble (double F)
 Converts a double to the nearest greater or equal integer. 更多...
 
static FORCEINLINE float CeilToFloat (float F)
 Converts a float to the nearest greater or equal integer. 更多...
 
static FORCEINLINE int32 CeilToInt (float F)
 Converts a float to the nearest greater or equal integer. 更多...
 
static FORCEINLINE uint32 CountLeadingZeros (uint32 Value)
 Counts the number of leading zeros in the bit representation of the 32-bit value 更多...
 
static FORCEINLINE uint64 CountLeadingZeros64 (uint64 Value)
 Counts the number of leading zeros in the bit representation of the 64-bit value 更多...
 
static FORCEINLINE uint8 CountLeadingZeros8 (uint8 Value)
 Counts the number of leading zeros in the bit representation of the 8-bit value 更多...
 
static FORCEINLINE uint32 CountTrailingZeros (uint32 Value)
 Counts the number of trailing zeros in the bit representation of the value 更多...
 
static FORCEINLINE uint64 CountTrailingZeros64 (uint64 Value)
 Counts the number of trailing zeros in the bit representation of the value 更多...
 
static CONSTEXPR FORCEINLINE double FloatSelect (double Comparand, double ValueGEZero, double ValueLTZero)
 Returns value based on comparand. 更多...
 
static CONSTEXPR FORCEINLINE float FloatSelect (float Comparand, float ValueGEZero, float ValueLTZero)
 Returns value based on comparand. 更多...
 
static FORCEINLINE uint32 FloorLog2 (uint32 Value)
 Computes the base 2 logarithm for an integer value that is greater than 0. 更多...
 
static FORCEINLINE uint64 FloorLog2_64 (uint64 Value)
 Computes the base 2 logarithm for a 64-bit value that is greater than 0. 更多...
 
static FORCEINLINE double FloorToDouble (double F)
 Converts a double to a less or equal integer. 更多...
 
static FORCEINLINE float FloorToFloat (float F)
 Converts a float to the nearest less or equal integer. 更多...
 
static FORCEINLINE int32 FloorToInt (float F)
 Converts a float to a nearest less or equal integer. 更多...
 
static CORE_API FORCENOINLINE float Fmod (float X, float Y)
 Returns the floating-point remainder of X / Y Warning: Always returns remainder toward 0, not toward the smaller multiple of Y. 更多...
 
static FORCEINLINE float Frac (float Value)
 Returns the fractional part of a float. 更多...
 
static FORCEINLINE float Fractional (float Value)
 Returns signed fractional part of a float. 更多...
 
static FORCEINLINE float FRand ()
 Returns a random float between 0 and 1, inclusive.
 
static CORE_API int32 GetRandSeed ()
 Returns the current seed for SRand().
 
static FORCEINLINE float InvSqrt (float F)
 Computes a fully accurate inverse square root
 
static FORCEINLINE float InvSqrtEst (float F)
 Computes a faster but less accurate inverse square root
 
static FORCEINLINE bool IsFinite (float A)
 Return true if value is finite (not NaN and not Infinity).
 
static FORCEINLINE bool IsNaN (float A)
 Return true if value is NaN (not a number).
 
template<class T >
static CONSTEXPR FORCEINLINE T Max (const T A, const T B)
 Returns higher value in a generic way
 
template<class T >
static FORCEINLINE T Max (const TArray< T > &Values, int32 *MaxIndex=NULL)
 Max of Array 更多...
 
template<class T >
static CONSTEXPR FORCEINLINE T Min (const T A, const T B)
 Returns lower value in a generic way
 
template<class T >
static FORCEINLINE T Min (const TArray< T > &Values, int32 *MinIndex=NULL)
 Min of Array 更多...
 
static FORCEINLINE double Modf (const double InValue, double *OutIntPart)
 Breaks the given value into an integral and a fractional part. 更多...
 
static FORCEINLINE float Modf (const float InValue, float *OutIntPart)
 Breaks the given value into an integral and a fractional part. 更多...
 
static FORCEINLINE uint32 MortonCode2 (uint32 x)
 Spreads bits to every other.
 
static FORCEINLINE uint32 MortonCode3 (uint32 x)
 Spreads bits to every 3rd.
 
static FORCEINLINE int32 Rand ()
 Returns a random integer between 0 and RAND_MAX, inclusive
 
static FORCEINLINE void RandInit (int32 Seed)
 Seeds global random number functions Rand() and FRand()
 
static FORCEINLINE uint32 ReverseMortonCode2 (uint32 x)
 Reverses MortonCode2. 更多...
 
static FORCEINLINE uint32 ReverseMortonCode3 (uint32 x)
 Reverses MortonCode3. 更多...
 
static FORCEINLINE double RoundToDouble (double F)
 Converts a double to the nearest integer. 更多...
 
static FORCEINLINE float RoundToFloat (float F)
 Converts a float to the nearest integer. 更多...
 
static FORCEINLINE int32 RoundToInt (float F)
 Converts a float to the nearest integer. 更多...
 
static FORCEINLINE uint32 RoundUpToPowerOfTwo (uint32 Arg)
 
template<class T >
static CONSTEXPR FORCEINLINE T Sign (const T A)
 Returns 1, 0, or -1 depending on relation of T to 0
 
static CORE_API float SRand ()
 Returns a seeded random float in the range [0,1), using the seed from SRandInit().
 
static CORE_API void SRandInit (int32 Seed)
 Seeds future calls to SRand()
 
static FORCEINLINE double TruncToDouble (double F)
 Converts a double to an integer value with truncation towards zero. 更多...
 
static FORCEINLINE float TruncToFloat (float F)
 Converts a float to an integer value with truncation towards zero. 更多...
 
static CONSTEXPR FORCEINLINE int32 TruncToInt (float F)
 Converts a float to an integer with truncation towards zero. 更多...
 

静态 Public 属性

static CORE_API const uint32 BitFlag [32]
 32 bit values where BitFlag[x] == (1<<x)
 

额外继承的成员函数

- Public 成员函数 继承自 FGenericPlatformMath
template<>
FORCEINLINE float Abs (const float A)
 Float specialization
 
template<>
FORCEINLINE VectorRegister Max (const VectorRegister A, const VectorRegister B)
 Returns the larger of the two values (operates on each component individually)
 
template<>
FORCEINLINE VectorRegister Min (const VectorRegister A, const VectorRegister B)
 Returns the smaller of the two values (operates on each component individually)
 

详细描述

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

成员函数说明

◆ ApplyScaleToFloat()

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

Handy to apply scaling in the editor

参数
Dstin and out

◆ CInterpTo()

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

◆ ClampAngle()

static CORE_API float FMath::ClampAngle ( float  AngleDegrees,
float  MinAngleDegrees,
float  MaxAngleDegrees 
)
static

Clamps an arbitrary angle to be between the given angles.

Will clamp to nearest boundary.

参数
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 clamped angle in the range -180..180.

◆ ClosestPointOnSegment()

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

Returns closest point on a segment to a given point.

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

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

◆ ClosestPointOnSegment2D()

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

FVector2D version of ClosestPointOnSegment.

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

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

◆ ClosestPointOnTetrahedronToPoint()

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

参数
Pointpoint to check distance for
A,B,C,Dfour points defining a tetrahedron
返回
Point on tetrahedron ABCD closest to given point

◆ ClosestPointOnTriangleToPoint()

static CORE_API 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"

参数
Pointpoint to check distance for
A,B,Ccounter clockwise ordering of points defining a triangle
返回
Point on triangle ABC closest to given point

◆ ComputeBaryCentric2D()

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

Computes the barycentric coordinates for a given point in a triangle

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

◆ ComputeBaryCentric3D()

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

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

◆ CubicInterp() [1/2]

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

In the case of quaternions, we use a bezier like approach.

T - Actual 'control' orientations.

◆ CubicInterp() [2/2]

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

Performs a cubic interpolation

参数
P- end points
T- tangent directions at end points
Alpha- distance along spline
返回
Interpolated value

◆ CubicInterpDerivative()

template<class T , class U >
static FORCEINLINE_DEBUGGABLE 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

参数
P- end points
T- tangent directions at end points
Alpha- distance along spline
返回
Interpolated value

◆ CubicInterpSecondDerivative()

template<class T , class U >
static FORCEINLINE_DEBUGGABLE 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

参数
P- end points
T- tangent directions at end points
Alpha- distance along spline
返回
Interpolated value

◆ DegreesToRadians()

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

Converts degrees to radians.

参数
DegValValue in degrees.
返回
Value in radians.

◆ DynamicWeightedMovingAverage()

static CORE_API float FMath::DynamicWeightedMovingAverage ( float  CurrentSample,
float  PreviousSample,
float  MaxDistance,
float  MinWeight,
float  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)

参数
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
返回
the next value in the series

◆ Eval()

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

参数
StrString containing the equation.
OutValuePointer to storage for the result.
返回
1 if successful, 0 if equation fails.

◆ FastAsin()

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

Computes the ASin of a scalar value.

参数
Valueinput angle
返回
ASin of Value

◆ FInterpTo()

static CORE_API float FMath::FInterpTo ( float  Current,
float  Target,
float  DeltaTime,
float  InterpSpeed 
)
static

Interpolate float from Current to Target.

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

◆ FixedTurn()

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

Returns a new rotation component value

参数
InCurrentis the current rotation value
InDesiredis the desired rotation value
InDeltaRateis the rotation amount to apply
返回
a new rotation component value

◆ Floor()

template<typename IntegralType , typename TEnableIf< TIsIntegral< IntegralType >::Value >::Type * = nullptr>
static FORCEINLINE IntegralType FMath::Floor ( IntegralType  I)
inlinestatic

Converts an integral type to a nearest less or equal integer.

Unlike std::floor, it returns an IntegralType.

◆ FormatIntToHumanReadable()

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

Formats an integer value into a human readable string (i.e.

12345 becomes "12,345")

参数
ValThe value to use
返回
FString The human readable string

◆ GetAzimuthAndElevation()

static CORE_API 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.
参数
DirectionDirection of target.
AxisXX component of reference system.
AxisYY component of reference system.
AxisZZ component of reference system.
返回
FVector2D X = Azimuth angle (in radians) (-PI, +PI) Y = Elevation angle (in radians) (-PI/2, +PI/2)

◆ GetBaryCentric2D()

static CORE_API 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 - simpler version

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

◆ GetDistanceWithinConeSegment()

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

参数
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).
返回
true if the point is within the cone, false otherwise.

◆ GetDotDistance()

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

参数
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.
返回
true if 'Direction' is facing AxisX (Direction dot AxisX >= 0.f)

◆ GetReflectionVector()

static CORE_API 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!

参数
DirectionDirection vector the ray is coming from.
SurfaceNormalA normal of the surface the ray should be reflected on.
返回
Reflected vector.

◆ GetTForSegmentPlaneIntersect()

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

参数
StartPoint- start point of segment
EndPoint- end point of segment
Plane- plane to intersect with
返回
time(T) of intersection

◆ InterpEaseIn()

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

Interpolate between A and B, applying an ease in function.

Exp controls the degree of the curve.

◆ InterpEaseInOut()

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

Interpolate between A and B, applying an ease in/out function.

Exp controls the degree of the curve.

◆ InterpEaseOut()

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

Interpolate between A and B, applying an ease out function.

Exp controls the degree of the curve.

◆ IntersectPlanes2()

bool FMath::IntersectPlanes2 ( FVector &  I,
FVector &  D,
const FPlane &  P1,
const FPlane &  P2 
)
inlinestatic

Compute intersection point and direction of line joining two planes.

Return 1 if valid, 0 if infinite.

◆ IntersectPlanes3()

bool FMath::IntersectPlanes3 ( FVector &  I,
const FPlane &  P1,
const FPlane &  P2,
const FPlane &  P3 
)
inlinestatic

Compute intersection point of three planes.

Return 1 if valid, 0 if infinite.

◆ IsNearlyEqual() [1/2]

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

Checks if two floating point numbers are nearly equal.

参数
AFirst number to compare
BSecond number to compare
ErrorToleranceMaximum allowed difference for considering them as 'nearly equal'
返回
true if A and B are nearly equal

◆ IsNearlyEqual() [2/2]

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

Checks if two floating point numbers are nearly equal.

参数
AFirst number to compare
BSecond number to compare
ErrorToleranceMaximum allowed difference for considering them as 'nearly equal'
返回
true if A and B are nearly equal

◆ IsNearlyEqualByULP() [1/2]

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

Check if two floating point numbers are nearly equal to within specific number of units of last place (ULP).

A single ULP difference between two floating point numbers means that they have an adjacent representation and that no other floating point number can be constructed to fit between them. This enables making consistent comparisons based on representational distance between floating point numbers, regardless of their magnitude.

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

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

◆ IsNearlyEqualByULP() [2/2]

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

Check if two floating point numbers are nearly equal to within specific number of units of last place (ULP).

A single ULP difference between two floating point numbers means that they have an adjacent representation and that no other floating point number can be constructed to fit between them. This enables making consistent comparisons based on representational distance between floating point numbers, regardless of their magnitude.

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

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

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

◆ IsNearlyZero() [1/2]

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

Checks if a floating point number is nearly zero.

参数
ValueNumber to compare
ErrorToleranceMaximum allowed difference for considering Value as 'nearly zero'
返回
true if Value is nearly zero

◆ IsNearlyZero() [2/2]

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

Checks if a floating point number is nearly zero.

参数
ValueNumber to compare
ErrorToleranceMaximum allowed difference for considering Value as 'nearly zero'
返回
true if Value is nearly zero

◆ IsPowerOfTwo()

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

Checks whether a number is a power of two.

参数
ValueNumber to check
返回
true if Value is a power of two

◆ LerpStable() [1/2]

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

◆ LerpStable() [2/2]

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

◆ LineBoxIntersection()

bool FMath::LineBoxIntersection ( const FBox &  Box,
const FVector &  Start,
const FVector &  End,
const FVector &  Direction,
const FVector &  OneOverDirection 
)
inlinestatic

Determines whether a line intersects a box.

This overload avoids the need to do the reciprocal every time.

◆ LinePlaneIntersection() [1/2]

FVector FMath::LinePlaneIntersection ( const FVector &  Point1,
const FVector &  Point2,
const FPlane &  Plane 
)
inlinestatic

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.

参数
Point1the first point defining the line
Point2the second point defining the line
Planethe plane
返回
The point of intersection between the line and the plane.

◆ LinePlaneIntersection() [2/2]

FVector FMath::LinePlaneIntersection ( const FVector &  Point1,
const FVector &  Point2,
const FVector &  PlaneOrigin,
const FVector &  PlaneNormal 
)
inlinestatic

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.

参数
Point1the first point defining the line
Point2the second point defining the line
PlaneOriginthe origin of the plane
PlaneNormalthe normal of the plane
返回
The point of intersection between the line and the plane.

◆ Log2()

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

Computes the base 2 logarithm of the specified value

参数
Valuethe value to perform the log on
返回
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

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

◆ MemoryTest()

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

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

参数
BaseAddressStarting address
NumBytesNumber of bytes to test (will be rounded down to a multiple of 4)
返回
true if the memory region passed the test

◆ PerlinNoise1D()

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

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

◆ PerlinNoise2D()

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

Generates a 1D Perlin noise sample at the given location.

Returns a continuous random value between -1.0 and 1.0.

参数
LocationWhere to sample
返回
Perlin noise in the range of -1.0 to 1.0

◆ PerlinNoise3D()

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

参数
LocationWhere to sample
返回
Perlin noise in the range of -1.0 to 1.0

◆ PlaneAABBIntersection()

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

Determine if a plane and an AABB intersect

参数
P- the plane to test
AABB- the axis aligned bounding box to test
返回
if collision occurs

◆ PlaneAABBRelativePosition()

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

参数
P- the plane to test
AABB- the axis aligned bounding box to test
返回
-1 if below, 1 if above, 0 if intersects

◆ PointDistToLine()

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

参数
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
返回
distance of Point from line defined by (Origin, Direction)

◆ PointDistToSegment()

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

参数
Pointpoint to check distance for
StartPointStartPoint of segment
EndPointEndPoint of segment
返回
closest distance from Point to segment defined by (StartPoint, EndPoint).

◆ PointDistToSegmentSquared()

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

参数
Pointpoint to check distance for
StartPointStartPoint of segment
EndPointEndPoint of segment
返回
square of the closest distance from Point to segment defined by (StartPoint, EndPoint).

◆ PointsAreCoplanar()

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

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

◆ QInterpTo()

static CORE_API FQuat FMath::QInterpTo ( const FQuat &  Current,
const FQuat &  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.

◆ RadiansToDegrees()

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

Converts radians to degrees.

参数
RadValValue in radians.
返回
Value in degrees.

◆ RandHelper()

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

Helper function for rand implementations.

Returns a random number in [0..A)

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

◆ 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

◆ RayPlaneIntersection()

static FVector FMath::RayPlaneIntersection ( const FVector &  RayOrigin,
const FVector &  RayDirection,
const FPlane &  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.

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

◆ RInterpTo()

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

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

参数
FFloating point value to convert
返回
The rounded integer

◆ RoundHalfFromZero()

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

参数
FFloating point value to convert
返回
The rounded integer

◆ RoundHalfToEven()

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

参数
FFloating point value to convert
返回
The rounded integer

◆ RoundHalfToZero()

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

参数
FFloating point value to convert
返回
The rounded integer

◆ RoundToNegativeInfinity()

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

参数
FFloating point value to convert
返回
The rounded integer

◆ RoundToPositiveInfinity()

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

参数
FFloating point value to convert
返回
The rounded integer

◆ RoundToZero()

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

参数
FFloating point value to convert
返回
The rounded integer

◆ SegmentDistToSegment()

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

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

◆ SegmentDistToSegmentSafe()

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

Find closest points between 2 segments.

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

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

◆ SegmentIntersection2D()

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

参数
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)
返回
true if intersection occurred

◆ SegmentPlaneIntersection()

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

参数
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)
返回
true if intersection occurred

◆ SegmentTriangleIntersection()

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

参数
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)
OutNormal- out var for the triangle normal
返回
true if intersection occurred

◆ SinCos()

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

Computes the sine and cosine of a scalar value.

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

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

参数
AMinimum value of X
BMaximum value of X
XParameter
返回
Smoothed value between 0 and 1

◆ SphereAABBIntersection()

FORCEINLINE bool FMath::SphereAABBIntersection ( const FVector &  SphereCenter,
const float  RadiusSquared,
const FBox &  AABB 
)
static

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

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

参数
Spherethe center of the sphere being tested against the AABB
RadiusSquaredthe size of the sphere being tested
AABBthe box being tested against
返回
Whether the sphere/box intersect or not.

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

参数
Spherethe center of the sphere being tested against the AABB
RadiusSquaredthe size of the sphere being tested
AABBthe box being tested against
返回
Whether the sphere/box intersect or not.

◆ SphereConeIntersection()

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

返回
true: cone and sphere do intersect, false otherwise

◆ SphereDistToLine()

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

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

◆ TruncateToHalfIfClose()

static CORE_API float FMath::TruncateToHalfIfClose ( float  F,
float  Tolerance = SMALL_NUMBER 
)
static

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

参数
ValueFloating point number to truncate
ToleranceMaximum allowed difference to 0.5 in order to truncate
返回
The truncated value

◆ Vector2DInterpTo()

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

Interpolate vector2D from Current to Target.

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

◆ VInterpTo()

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

◆ VRandCone() [1/2]

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

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

Returns a normalized vector.

◆ VRandCone() [2/2]

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

static CORE_API float FMath::WeightedMovingAverage ( float  CurrentSample,
float  PreviousSample,
float  Weight 
)
inlinestatic

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

参数
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
返回
the next value in the series

◆ WindRelativeAnglesDegrees()

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

参数
Angle0The first angle that we wind relative to.
Angle1The second angle that we may wind relative to the first.

该结构体的文档由以下文件生成: