MW UNITY NAMESPACE








































[StructLayout(LayoutKind.Sequential, Size = 1)] public struct

FMath


A Mathematics Function interface.



public const float

kPhi

The golden ratio.



public const float

kE

Euler's number. (e)



public const float

kSqrt2

Shorthand for writing FSqrt(2).



public const float

kSqrt3

Shorthand for writing FSqrt(3).



public const float

kPI

PI



public const float

kInversePI

Shorthand for writing 1 / kPI.



public const float

kHalfPI

Shorthand for writing kPI * kHalf.



public const float

k2PI

Shorthand for writing kPI * 2f.



public const float

k1To255RGB

The conversion from 0-1 to 0-255.



public const float

kOneThird

Shorthand for writing / 3.



public const float

kTwoThirds

Shorthand for writing / 1.5.



public static bool

IsPowerOfTwo (float F)



public static float

Sine (float F)



public static float

Cos (float F)



public static float

Tan (float F)



public static float

ArcSine (float F)



public static float

ArcCos (float F)



public static float

ArcTan (float F)



public static float

ArcTan2 (float Y, float X)



public static float

Sqrt (float F, bool bWithAccuracy, int NewtonIterations)



public static float

InvSqrt (float F, bool bWithAccuracy, int NewtonIterations)



public static sbyte

Abs (sbyte B)



public static short

Abs (short S)



public static int

Abs (int I)



public static float

Abs (float F)



public static double

Abs (double D)



public static sbyte

Min (sbyte A, sbyte B)



public static short

Min (short A, short B)



public static int

Min (int A, int B)



public static float

Min (float A, float B)



public static double

Min (double A, double B)



public static sbyte

Max (sbyte A, sbyte B)



public static short

Max (short A, short B)



public static int

Max (int A, int B)



public static float

Max (float A, float B)



public static double

Max (double A, double B)



public static sbyte

Min (sbyte[] Params)



public static short

Min (short[] Params)



public static int

Min (int[] Params)



public static float

Min (float[] Params)



public static double

Min (double[] Params)



public static sbyte

Max (sbyte[] Params)



public static short

Max (short[] Params)



public static int

Max (int[] Params)



public static float

Max (float[] Params)



public static double

Max (double[] Params)



public static float

Power (float F, float P)



public static float

Log (float F)



public static float

Log10 (float F)



public static float

Log (float F, float Base)



public static float

Ceiling (float F)



public static int

CeilingInt (float F)



public static float

Floor (float F)



public static int

FloorInt (float F)



public static float

Round (float F)



public static int

RoundInt (float F)



public static int

Sign (sbyte B)

Returns:

1 if positive, -1 if negative, 0 if zero.



public static int

Sign (short S)

Returns:

1 if positive, -1 if negative, 0 if zero.



public static int

Sign (int I)

Returns:

1 if positive, -1 if negative, 0 if zero.



public static int

Sign (float F)

Returns:

1 if positive, -1 if negative, 0 if zero.



public static int

Sign (double D)

Returns:

1 if positive, -1 if negative, 0 if zero.



public static void

Clamp (sbyte& B, sbyte Min, sbyte Max)

Summary:

Clamps B between Min and Max.



public static void

Clamp (short& S, short Min, short Max)

Summary:

Clamps S between Min and Max.



public static void

Clamp (int& I, int Min, int Max)

Summary:

Clamps I between Min and Max.



public static void

Clamp (float& F, float Min, float Max)

Summary:

Clamps F between Min and Max.



public static void

Clamp (double& D, double Min, double Max)

Summary:

Clamps D between Min and Max.



public static sbyte

Clamp (sbyte B, sbyte Min, sbyte Max)

Summary:

Clamps B between Min and Max.



public static short

Clamp (short S, short Min, short Max)

Summary:

Clamps S between Min and Max.



public static int

Clamp (int I, int Min, int Max)

Summary:

Clamps I between Min and Max.



public static float

Clamp (float F, float Min, float Max)

Summary:

Clamps F between Min and Max.



public static double

Clamp (double D, double Min, double Max)

Summary:

Clamps D between Min and Max.



public static float

IfZeroThenZero (float F, float Tolerance)

Summary:

If F is considered zero, return zero.

Returns:

F < ZeroThreshold ? 0F : F



public static double

IfZeroThenZero (double D, double Tolerance)

Summary:

If D is considered zero, return zero.

Returns:

D < ZeroThreshold ? 0.0 : D



public static float

IfZeroThenZero (float& F, float Tolerance)

Summary:

If F is considered zero, return zero.

Returns:

F < ZeroThreshold ? 0F : F



public static double

IfZeroThenZero (double& D, double Tolerance)

Summary:

If D is considered zero, return zero.

Returns:

D < ZeroThreshold ? 0.0 : D



public static float

DeltaAngle (float L, float R)

Summary:

Difference between two angles.

Returns:

The difference between two angles.



public static float

Lerp (float A, float B, float Alpha)

Summary:

Interpolates between A and B by Alpha.

Returns:

Interpolated number Alpha percentage between A and B.



public static float

LerpAngle (float A, float B, float Alpha)

Summary:

Interpolates between two Angles.

Returns:

Interpolated angle between A and B by Alpha.



public static float

InvLerp (float A, float B, float F)

Summary:

Inverse Lerp from A to B by F.

F:

        Current between A and B.

Returns:

Percentage F is towards B, relative to A.



public static float

Approach (float Now, float Target, float MaximumDelta)

Summary:

Approach Now to Target by MaximumDelta.

MaximumDelta:

        Step from Now towards Target.



public static float

ApproachAngle (float Now, float Target, float MaximumDelta)

Summary:

Approach Now degrees to Target degrees by MaximumDelta.

MaximumDelta:

        Angle step Now towards Target.



public static float

Smooth (float From, float To, float Alpha)

Summary:

Smooths the transition From -> To by Aloha.

Alpha:

        Percentage from From -> To.



public static bool

IsApproxEqual (float A, float B, float Tolerance)

Summary:

If A and B are within Tolerance of each other.

Tolerance:

        Equality threshold.

Returns:

Abs(A - B) <= Tolerance.



public static bool

IsApproxEqual (MVector A, MVector B, float Tolerance)

Summary:

If two MVectors are approximately equal across all components.

Remarks:

Compares MVector.SqrMagnitude against Tolerance.

Tolerance:

        Equality threshold.

Returns:

if the square magnitude of A - B are within +-Tolerance.



public static float

SmoothDamp (float Now, float Target, float& RefVelocity, float SmoothTime, float DeltaTime, float Terminal)

Summary:

Smooths the approach velocity of numerical values.

Params:

Now:

        Current Angle.

Target:

        Target Angle.

RefVelocity:

        Reference to the current velocity of the number from Now to Target.

SmoothTime:

        Time it should take for Now to reach Target.

DeltaTime:

        Time since the last call to this function.

Terminal:

        The maximum increment Now should take to reach Target.

Returns:

A smoothed approach from Now to Target.



public static float

SmoothDampAngle (float Now, float Target, float& RefVelocity, float SmoothTime, float DeltaTime, float Terminal)

Summary:

Smooths the velocity of angles in a trigonometry space.

Params:

Now:

        Current Angle.

Target:

        Target Angle.

RefVelocity:

        Reference to the current velocity of the Angle from Now to Target.

SmoothTime:

        Time it should take for Now to reach Target.

DeltaTime:

        Time since the last call to this function.

Terminal:

        The maximum increment Now should take to reach Target.

Returns:

A smoothed approach from Now to Target, considering angles.



public static float

Oscillate (float F, float Magnitude)

Summary:

Ping-pongs F by Magnitude.

Params:

F:

        The number to ping-pong.

Magnitude:

        The length of the ping-pong.

Returns:

An oscillating number that goes between +- Magnitude.



public static float

PreviousMultiple (float F, float Multiple)

Summary:

The previous factor of Multiple from F.

Params:

F:

        The base number.

Multiple:

        The factor.

Returns:

A factor of Multiple before F.



public static float

NextMultiple (float F, float Multiple)

Summary:

The next factor of Multiple from F.

Params:

F:

        The base number

Multiple:

        The factor.

Returns:

A factor of Multiple after F.



public static float

ClosestMultiple (float F, float Multiple)

Summary:

The closest factor of Multiple from F.

Params:

F:

        The base number.

Multiple:

        The factor.

Returns:

A factor of Multiple that F is closest to.