FMath

Inheritance Hierarchy

Syntax

struct FMath : public FLinuxPlatformMath

Remarks

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

Functions

Name Description

Public function Static

void

 

ApplyScaleToFloat

(
    float& Dst,
    const FVector & DeltaScale,
    float Magnitude
)

Handy to apply scaling in the editor

Public function Static

FQuat

 

BiLerp

(
    const FQuat & P00,
    const FQuat & P10,
    const FQuat & P01,
    const FQuat & P11,
    float FracX,
    float FracY
)

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

Public function Static

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

Public function Static

void

 

CartesianToPolar

(
    const FVector2D InCart,
    FVector2D & OutPolar
)

Converts given Cartesian coordinate pair to Polar coordinate system.

Public function Static

void

 

CartesianToPolar

(
    const float X,
    const float Y,
    float& OutRad,
    float& OutAng
)

Converts given Cartesian coordinate pair to Polar coordinate system.

Public function Static

FLinearColor

 

CInterpTo

(
    const FLinearColor & Current,
    const FLinearColor & Target,
    float DeltaTime,
    float InterpSpeed
)

Interpolate Linear Color from Current to Target.

Public function Static

T

 

Clamp

(
    const T X,
    const T Min,
    const T Max
)

Clamps X to be between Min and Max, inclusive

Public function Static

float

 

ClampAngle

(
    float AngleDegrees,
    float MinAngleDegrees,
    float MaxAngleDegrees
)

Clamps an arbitrary angle to be between the given angles. Will clamp to nearest boundary.

Public function Static

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

Public function Static

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

Public function Static

FVector

 

ClosestPointOnSegment

(
    const FVector & Point,
    const FVector & StartPoint,
    const FVector & EndPoint
)

Returns closest point on a segment to a given point.

Public function Static

FVector2D

 

ClosestPointOnSegment2D

(
    const FVector2D & Point,
    const FVector2D & StartPoint,
    const FVector2D & EndPoint
)

FVector2D version of ClosestPointOnSegment.

Public function Static

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.

Public function Static

FVector

 

ClosestPointOnTriangleToPoint

(
    const FVector & Point,
    const FVector & A,
    const FVector & B,
    const FVector & C
)

Returns closest point on a triangle to a point.

Public function Static

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

Public function Static

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)

Public function Static

FSphere

 

ComputeBoundingSphereForCone

(
    FVector const& ConeOrigin,
    FVector const& ConeDirection,
    float ConeRadius,
    float CosConeAngle,
    float SinConeAngle
)

Computes minimal bounding sphere encompassing given cone

Public function Static

uint32

 

ComputeProjectedSphereScissorRect

(
    FIntRect & InOutScissorRect,
    FVector SphereOrigin,
    float Radius,
    FVector ViewOrigin,
    const FMatrix & ViewMatrix,
    const FMatrix & ProjMatrix
)

InOutScissorRect should be set to View.ViewRect before the call

Public function Static

U

 

CubicCRSplineInterp

(
    const U& P0,
    const U& P1,
    const U& P2,
    const U& P3,
    const float T0,
    const float T1,
    const float T2,
    const float T3,
    const float T
)

Cubic Catmull-Rom Spline interpolation.

Public function Static

U

 

CubicCRSplineInterpSafe

(
    const U& P0,
    const U& P1,
    const U& P2,
    const U& P3,
    const float T0,
    const float T1,
    const float T2,
    const float T3,
    const float T
)

Same as CubicCRSplineInterp but with additional saftey checks. If the checks fail P1 is returned.

Public function 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. T - Actual 'control' orientations.

Public function Static

T

 

CubicInterp

(
    const T& P0,
    const T& T0,
    const T& P1,
    const T& T1,
    const U& A
)

Performs a cubic interpolation

Public function Static

T

 

CubicInterpDerivative

(
    const T& P0,
    const T& T0,
    const T& P1,
    const T& T1,
    const U& A
)

Performs a first derivative cubic interpolation

Public function Static

T

 

CubicInterpSecondDerivative

(
    const T& P0,
    const T& T0,
    const T& P1,
    const T& T1,
    const U& A
)

Performs a second derivative cubic interpolation

Public function Static

auto

 

DegreesToRadians

(
    T const& DegVal
)

Converts degrees to radians.

Public function Static

T

 

DivideAndRoundDown

(
    T Dividend,
    T Divisor
)

Divides two integers and rounds down

Public function Static

T

 

DivideAndRoundNearest

(
    T Dividend,
    T Divisor
)

Divides two integers and rounds to nearest

Public function Static

T

 

DivideAndRoundUp

(
    T Dividend,
    T Divisor
)

Divides two integers and rounds up

Public function Static

bool

 

Eval

(
    FString Str,
    float& OutValue
)

Evaluates a numerical equation.

Public function 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

Public function Static

float

 

FastAsin

(
    float Value
)

Computes the ASin of a scalar value.

Public function Static

float

 

FindDeltaAngleDegrees

(
    float A1,
    float A2
)

Find the smallest angle between two headings (in degrees)

Public function Static

float

 

FindDeltaAngleRadians

(
    float A1,
    float A2
)

Find the smallest angle between two headings (in radians)

Public function Static

float

 

FInterpConstantTo

(
    float Current,
    float Target,
    float DeltaTime,
    float InterpSpeed
)

Interpolate float from Current to Target with constant step

Public function Static

float

 

FInterpTo

(
    float Current,
    float Target,
    float DeltaTime,
    float InterpSpeed
)

Interpolate float from Current to Target.

Public function Static

float

 

FixedTurn

(
    float InCurrent,
    float InDesired,
    float InDeltaRate
)

Returns a new rotation component value

Public function Static

FString

 

FormatIntToHumanReadable

(
    int32 Val
)

Formats an integer value into a human readable string (i.e. 12345 becomes "12,345")

Public function Static

float

 

FRandRange

(
    float InMin,
    float InMax
)

Util to generate a random number in a range.

Public function Static

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

Public function Static

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

Public function Static

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)

Public function Static

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

Public function Static

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.

Public function Static

float

 

GetMappedRangeValueUnclamped

(
    const FVector2D & InputRange,
    const FVector2D & OutputRange,
    const float Value
)

Transform the given Value relative to the input range to the Output Range.

Public function Static

float

 

GetRangePct

(
    float MinValue,
    float MaxValue,
    float Value
)

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

Public function Static

float

 

GetRangePct

(
    FVector2D const& Range,
    float Value
)

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

Public function Static

float

 

GetRangeValue

(
    FVector2D const& Range,
    float Pct
)

Basically a Vector2d version of Lerp.

Public function Static

FVector

 

GetReflectionVector

(
    const FVector & Direction,
    const FVector & SurfaceNormal
)

Given a direction vector and a surface normal, returns the vector reflected across the surface normal.

Public function Static

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)

Public function Static

int32

 

GreatestCommonDivisor

(
    int32 a,
    int32 b
)

Use the Euclidean method to find the GCD.

Public function Static

float

 

GridSnap

(
    float Location,
    float Grid
)

Snaps a value to the nearest grid multiple

Public function Static

double

 

GridSnap

(
    double Location,
    double Grid
)

Snaps a value to the nearest grid multiple

Public function Static

T

 

InterpCircularIn

(
    const T& A,
    const T& B,
    float Alpha
)

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

Public function Static

T

 

InterpCircularInOut

(
    const T& A,
    const T& B,
    float Alpha
)

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

Public function Static

T

 

InterpCircularOut

(
    const T& A,
    const T& B,
    float Alpha
)

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

Public function Static

T

 

InterpEaseIn

(
    const T& A,
    const T& B,
    float Alpha,
    float Exp
)

Interpolate between A and B, applying an ease in function. Exp controls the degree of the curve.

Public function Static

T

 

InterpEaseInOut

(
    const T& A,
    const T& B,
    float Alpha,
    float Exp
)

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

Public function Static

T

 

InterpEaseOut

(
    const T& A,
    const T& B,
    float Alpha,
    float Exp
)

Interpolate between A and B, applying an ease out function. Exp controls the degree of the curve.

Public function Static

T

 

InterpExpoIn

(
    const T& A,
    const T& B,
    float Alpha
)

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

Public function Static

T

 

InterpExpoInOut

(
    const T& A,
    const T& B,
    float Alpha
)

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

Public function Static

T

 

InterpExpoOut

(
    const T& A,
    const T& B,
    float Alpha
)

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

Public function Static

T

 

InterpSinIn

(
    const T& A,
    const T& B,
    float Alpha
)

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

Public function Static

T

 

InterpSinInOut

(
    const T& A,
    const T& B,
    float Alpha
)

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

Public function Static

T

 

InterpSinOut

(
    const T& A,
    const T& B,
    float Alpha
)

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

Public function Static

T

 

InterpStep

(
    const T& A,
    const T& B,
    float Alpha,
    int32 Steps
)

Interpolation between A and B, applying a step function.

Public function Static

bool

 

IntersectPlanes2

(
    FVector & I,
    FVector & D,
    const FPlane & P1,
    const FPlane & P2
)

Compute intersection point and direction of line joining two planes.

Public function Static

bool

 

IntersectPlanes3

(
    FVector & I,
    const FPlane & P1,
    const FPlane & P2,
    const FPlane & P3
)

Compute intersection point of three planes. Return 1 if valid, 0 if infinite.

Public function Static

bool

 

IsNearlyEqual

(
    double A,
    double B,
    double ErrorTolerance
)

Checks if two floating point numbers are nearly equal.

Public function Static

bool

 

IsNearlyEqual

(
    float A,
    float B,
    float ErrorTolerance
)

Checks if two floating point numbers are nearly equal.

Public function Static

bool

 

IsNearlyZero

(
    float Value,
    float ErrorTolerance
)

Checks if a floating point number is nearly zero.

Public function Static

bool

 

IsNearlyZero

(
    double Value,
    double ErrorTolerance
)

Checks if a floating point number is nearly zero.

Public function Static

bool

 

IsPowerOfTwo

(
    T Value
)

Checks whether a number is a power of two.

Public function Static

bool

 

IsWithin

(
    const U& TestValue,
    const U& MinValue,
    const U& MaxValue
)

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

Public function Static

bool

 

IsWithinInclusive

(
    const U& TestValue,
    const U& MinValue,
    const U& MaxValue
)

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

Public function Static

int32

 

LeastCommonMultiplier

(
    int32 a,
    int32 b
)

LCM = a/gcd * b a and b are the number we want to find the lcm

Public function Static

T

 

Lerp

(
    const T& A,
    const T& B,
    const U& Alpha
)

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

Public function Static

FRotator

 

Lerp

(
    const FRotator & A,
    const FRotator & B,
    const U& Alpha
)

Rotator specific interpolation.

Public function Static

FQuat

 

Lerp

(
    const FQuat & A,
    const FQuat & B,
    const U& Alpha
)

FMath inline functions

Public function

VectorRegist ...

 

Lerp

(
    const VectorRegister & A,
    const VectorRegister & B,
    const VectorRegister & Alpha
)

Specialization of Lerp template that works with vector registers.

Public function Static

FRotator

 

LerpRange

(
    const FRotator & A,
    const FRotator & B,
    const U& Alpha
)

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

Public function Static

T

 

LerpStable

(
    const T& A,
    const T& B,
    float Alpha
)

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

Public function Static

T

 

LerpStable

(
    const T& A,
    const T& B,
    double Alpha
)

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

Public function Static

bool

 

LineBoxIntersection

(
    const FBox & Box,
    const FVector & Start,
    const FVector & End,
    const FVector & Direction
)

Determines whether a line intersects a box.

Public function 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.

Public function Static

bool

 

LineExtentBoxIntersection

(
    const FBox & inBox,
    const FVector & Start,
    const FVector & End,
    const FVector & Extent,
    FVector & HitLocation,
    FVector & HitNormal,
    float& HitTime
)

Swept-Box vs Box test

Public function 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.

Public function Static

FVector

 

LinePlaneIntersection

(
    const FVector & Point1,
    const FVector & Point2,
    const FPlane & Plane
)

Find the intersection of a line and a plane.

Public function Static

bool

 

LineSphereIntersection

(
    const FVector & Start,
    const FVector & Dir,
    float Length,
    const FVector & Origin,
    float Radius
)

Determines whether a line intersects a sphere.

Public function Static

float

 

Log2

(
    float Value
)

Computes the base 2 logarithm of the specified value

Public function Static

float

 

MakePulsatingValue

(
    const double InCurrentTime,
    const float InPulsesPerSecond,
    const float InPhase
)

Simple function to create a pulsating scalar value

Public function Static

T

 

Max3

(
    const T A,
    const T B,
    const T C
)

Returns highest of 3 values

Public function Static

bool

 

MemoryTest

(
    void* BaseAddress,
    uint32 NumBytes
)

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

Public function Static

T

 

Min3

(
    const T A,
    const T B,
    const T C
)

Returns lowest of 3 values

Public function Static

float

 

PerlinNoise1D

(
    const float Value
)

Generates a 1D Perlin noise from the given value.

Public function Static

bool

 

PlaneAABBIntersection

(
    const FPlane & P,
    const FBox & AABB
)

Determine if a plane and an AABB intersect

Public function Static

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

Public function Static

bool

 

PointBoxIntersection

(
    const FVector & Point,
    const FBox & Box
)

Determines whether a point is inside a box.

Public function Static

float

 

PointDistToLine

(
    const FVector & Point,
    const FVector & Direction,
    const FVector & Origin
)

Calculates the distance of a given Point in world space to a given line, defined by the vector couple (Origin, Direction).

Public function Static

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

Public function Static

float

 

PointDistToSegment

(
    const FVector & Point,
    const FVector & StartPoint,
    const FVector & EndPoint
)

Returns distance from a point to the closest point on a segment.

Public function Static

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.

Public function Static

bool

 

PointsAreCoplanar

(
    const TArray < FVector >& Points,
    const float Tolerance
)

Determines whether a given set of points are coplanar, with a tolerance.

Public function Static

void

 

PolarToCartesian

(
    const float Rad,
    const float Ang,
    float& OutX,
    float& OutY
)

Converts given Polar coordinate pair to Cartesian coordinate system.

Public function Static

void

 

PolarToCartesian

(
    const FVector2D InPolar,
    FVector2D & OutCart
)

Converts given Polar coordinate pair to Cartesian coordinate system.

Public function Static

FQuat

 

QInterpConstantTo

(
    const FQuat & Current,
    const FQuat & Target,
    float DeltaTime,
    float InterpSpeed
)

Interpolate quaternion from Current to Target with constant step (in radians)

Public function Static

FQuat

 

QInterpTo

(
    const FQuat & Current,
    const FQuat & Target,
    float DeltaTime,
    float InterpSpeed
)

Interpolate quaternion from Current to Target.

Public function Static

uint8

 

Quantize8SignedByte

(
    float x
)

Public function Static

uint8

 

Quantize8UnsignedByte

(
    float x
)

Public function Static

auto

 

RadiansToDegrees

(
    T const& RadVal
)

Converts radians to degrees.

Public function Static

bool

 

RandBool()

Util to generate a random boolean.

Public function Static

int32

 

RandHelper

(
    int32 A
)

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

Public function Static

int64

 

RandHelper64

(
    int64 A
)

Public function Static

FVector

 

RandPointInBox

(
    const FBox & Box
)

Returns a random point within the passed in bounding box

Public function Static

FVector2D

 

RandPointInCircle

(
    float CircleRadius
)

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

Public function Static

int32

 

RandRange

(
    int32 Min,
    int32 Max
)

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

Public function Static

float

 

RandRange

(
    float InMin,
    float InMax
)

Util to generate a random number in a range.

Public function Static

int64

 

RandRange

(
    int64 Min,
    int64 Max
)

Public function Static

FVector

 

RayPlaneIntersection

(
    const FVector & RayOrigin,
    const FVector & RayDirection,
    const FPlane & Plane
)

Find the intersection of a ray and a plane.

Public function Static

FRotator

 

RInterpConstantTo

(
    const FRotator & Current,
    const FRotator & Target,
    float DeltaTime,
    float InterpSpeed
)

Interpolate rotator from Current to Target with constant step

Public function Static

FRotator

 

RInterpTo

(
    const FRotator & Current,
    const FRotator & Target,
    float DeltaTime,
    float InterpSpeed
)

Interpolate rotator from Current to Target.

Public function Static

double

 

RoundFromZero

(
    double F
)

Public function Static

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

Public function Static

double

 

RoundHalfFromZero

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

Public function Static

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

Public function Static

double

 

RoundHalfToEven

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

Public function Static

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

Public function Static

double

 

RoundHalfToZero

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

Public function Static

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

Public function Static

double

 

RoundToNegativeInfinity

(
    double F
)

Public function Static

float

 

RoundToNegativeInfinity

(
    float F
)

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

Public function Static

float

 

RoundToPositiveInfinity

(
    float F
)

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

Public function Static

double

 

RoundToPositiveInfinity

(
    double F
)

Public function Static

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

Public function Static

double

 

RoundToZero

(
    double F
)

Public function Static

void

 

SegmentDistToSegment

(
    FVector A1,
    FVector B1,
    FVector A2,
    FVector B2,
    FVector & OutP1,
    FVector & OutP2
)

Find closest points between 2 segments.

Public function Static

void

 

SegmentDistToSegmentSafe

(
    FVector A1,
    FVector B1,
    FVector A2,
    FVector B2,
    FVector & OutP1,
    FVector & OutP2
)

Find closest points between 2 segments.

Public function Static

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.

Public function Static

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.

Public function Static

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.

Public function 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

Public function Static

void

 

SinCos

(
    float* ScalarSin,
    float* ScalarCos,
    float Value
)

Computes the sine and cosine of a scalar value.

Public function 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.

Public function Static

bool

 

SphereAABBIntersection

(
    const FVector & SphereCenter,
    const float RadiusSquared,
    const FBox & AABB
)

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

Public function Static

bool

 

SphereAABBIntersection

(
    const FSphere & Sphere,
    const FBox & AABB
)

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

Public function Static

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)

Public function Static

void

 

SphereDistToLine

(
    FVector SphereOrigin,
    float SphereRadius,
    FVector LineOrigin,
    FVector LineDir,
    FVector & OutClosestPoint
)

Find closest point on a Sphere to a Line.

Public function Static

T

 

Square

(
    const T A
)

Multiples value by itself

Public function Static

float

 

UnwindDegrees

(
    float A
)

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

Public function Static

float

 

UnwindRadians

(
    float A
)

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

Public function Static

FVector2D

 

Vector2DInterpConstantTo

(
    const FVector2D & Current,
    const FVector2D & Target,
    float DeltaTime,
    float InterpSpeed
)

Interpolate vector2D from Current to Target with constant step

Public function Static

FVector2D

 

Vector2DInterpTo

(
    const FVector2D & Current,
    const FVector2D & Target,
    float DeltaTime,
    float InterpSpeed
)

Interpolate vector2D from Current to Target.

Public function Static

FVector

 

VInterpConstantTo

(
    const FVector Current,
    const FVector & Target,
    float DeltaTime,
    float InterpSpeed
)

Interpolate vector from Current to Target with constant step

Public function Static

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.

Public function Static

FVector

 

VInterpTo

(
    const FVector & Current,
    const FVector & Target,
    float DeltaTime,
    float InterpSpeed
)

Interpolate vector from Current to Target.

Public function Static

FVector

 

VRand()

Return a uniformly distributed random unit length vector = point on the unit sphere surface.

Public function Static

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.

Public function Static

FVector

 

VRandCone

(
    FVector const& Dir,
    float HorizontalConeHalfAngleRad,
    float VerticalConeHalfAngleRad
)

This is a version of VRandCone that handles "squished" cones, i.e. with different angle limits in the Y and Z axes.

Public function Static

void

 

WindRelativeAnglesDegrees

(
    float InAngle0,
    float& InOutAngle1
)

Given two angles in degrees, 'wind' the rotation in Angle1 so that it avoids >180 degree flips.

Constants

Name

Description

BitFlag

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

Deprecated Functions

Name Description

Public function Static

float

 

FindDeltaAngle

(
    float A1,
    float A2
)

Please use FindDeltaAngleRadians(float A1, float A2) instead of FindDeltaAngle(float A1, float A2) .

References

Module

Core

Header

Runtime/Core/Public/Math/UnrealMathUtility.h