MW UNITY NAMESPACE








































public static class

Mathematics




public static float

Acceleration (EEquation Equation, float CurrentSpeed, float RateOfAcceleration, float Terminal, float DeltaTime)

Summary:

The EEquation to use to accelerate.

Params:

Equation:

        The EEquation to use to accelerate.

CurrentSpeed:

        The current speed of the acceleration.

RateOfAcceleration:

        The rate to accelerate towards to terminal from current speed.

Terminal:

        The maximum speed.

DeltaTime:

        Delta time between two Speed calculations.

Returns:

The acceleration value using EEquation, using the current speed and rate of acceleration towards terminal over Time.deltaTime.



public static float

Deceleration (float CurrentSpeed, float TargetVelocity, float DeltaTime)

Summary:

The rate of deceleration.



[Obsolete] public static float

AccelerationRate (Rigidbody Self, float Speed)

Params:

Self:

        The Rigidbody to calculate an acceleration rate.

Speed:

        The current speed of the Rigidbody in EUnit.MetresPerSecond.

Returns:

The float rate of movement in EUnit.MetresPerSecond.



public static float

AccelerationRate (MVector LastPosition, MVector ThisPosition, float DeltaTime)

Summary:

The rate of acceleration in m/s^2.

DeltaTime:

        The difference in time between LastPosition and ThisPosition in seconds.

Returns:

The rate of acceleration if an object went from LastPosition to ThisPosition in DeltaTime.



public static float

Speed (Rigidbody Self, EUnit Unit)

Summary:

Converts a Rigidbody's speed from metres per second to UUnit.

Params:

Self:

        The Rigidbody to read a speed from.

Unit:

        The desired EUnit of measurement.

Returns:

A speed reading from self in EUnit of measurement.



public static MVector

PredictiveProjectile (Rigidbody Projectile, Rigidbody Target)

Summary:

The direction to intercept Target relative to Projectile.

Remarks:

Requires movement in BOTH Rigidbodies. This function was designed specifically for aircraft.

Params:

Projectile:

        The Rigidbody predicting the movement of RBTarget.

Target:

        The Rigidbody to predict.



public static MVector

PredictiveProjectile (MVector LaunchPosition, float ConstantMoveSpeed, MVector TargetVelocity, MVector TargetPosition)

Summary:

Predicts the path of a target's movement for a projectile to be launched.

Params:

LaunchPosition:

        World location of where a projectile will be launched.

ConstantMoveSpeed:

        The movement speed of the projectile that will be launched.

TargetVelocity:

        The direction of where the target is heading and the speed it is travelling at.

TargetPosition:

        The world location of the target.

Returns:

A world location of where a projectile should aim towards so that it intercepts the target.



public static bool

IsPowerOfTwo (int Number)

Summary:

Whether Number is a power of two.

Params:

Number:

        The number to check.

Returns:

Number & (Number - 1) == 0.



public static int

GreatestCommonDivisor (int A, int B)

Summary:

The greatest common divisor of A and B.



public static int

LowestCommonMultiple (int A, int B)

Summary:

The lowest common multiple of A and B.



public static float

Wrap (float F, float Min, float Max)

Summary:

Wraps f between Min and Max.

Params:

F:

        The float number to wrap.

Min:

        The minimum value to wrap.

Max:

        The maximum value to wrap.



public static float

Wrap (int n, int Min, int Max)

Summary:

Wraps n between Min and Max.

Params:

n:

        The float number to wrap.

Min:

        The minimum value to wrap.

Max:

        The maximum value to wrap.



public static bool

Parallel (MVector M1, MVector M2, float ParallelThreshold)

Summary:

Whether M1 is parallel to M2 within ParallelThreshold.

Params:

M1:

        Whether this vector is parallel to the other.

M2:

        Whether this vector is parallel to the other.

ParallelThreshold:

        The threshold to consider parallel vectors.



public static bool

IsNormalised (MVector Vector)

Summary:

Whether Vector has been normalised.

Params:

Vector:

        The vector to check.



public static float

AngleFromVector3D (Vector3 Direction)

Summary:

The angle in degrees pointing towards Direction using the X-Axis and Z-Axis. (For 3D space)

Params:

Direction:

        The direction to calculate an angle towards.



public static float

AngleFromVector2D (Vector3 Direction)

Summary:

The angle in degrees pointing towards Direction using the X-Axis and Y-Axis. (For 2D space)

Params:

Direction:

        The direction to calculate an angle towards.



public static Quaternion

DirectionToQuat (Vector3 From, Vector3 To)

Summary:

Converts a normalised vector direction to a Quaternion rotation

Remarks:

Roll (Z) cannot be calculated from a direction vector.

Params:

From:

        Origin

To:

        Target

Returns:

Quaternion rotation from to.



public static Quaternion

V2Q (Vector3 V)

Summary:

Converts a normalised vector to a Quaternion rotation.

Remarks:

Roll (Z) cannot be calculated from a direction vector.

Params:

V:

        Normalised direction vector.

Returns:

Quaternion rotation without roll.



public static Vector3

V2PYR (Vector3 V)

Summary:

Converts V to Pitch Yaw Roll.

Remarks:

Roll (Z) cannot be calculated from a direction vector.

Params:

V:

        Normalised direction vector.

Returns:

X = Pitch, Y = Yaw, Z = Roll = 0.



public static void

SinCos (float& Sine, float& Cosine, float Angle, bool bUseExactValue)

Summary:

The 11-Degree Minimax Approximation Sine and 10-Degree Minimax Approximation Cosine over an angle.

Remarks:

Out Sine and Cosine are accurate to 2.4E-5 of the real sine and cosine of Angle.

Params:

Sine:

        The Sine result over AngleInDegrees.

Cosine:

        The Cosine result over AngleInDegrees.

Angle:

        The angle in degrees.

bUseExactValue:

        True to use MathF.Sin and MathF.Cos for the exact SinCos values.



public static float

SqrDistance (Vector3 L, Vector3 R)

Summary:

Calculates the Square Distance between two Vector3s.

Returns:

The Square Distance between L and R.



public static float

Distance (Vector3 L, Vector3 R)

Summary:

A fast version of Vector3.Distance().

Returns:

The distance between L and R.



public static float

ArcDistance (MVector A, MVector B, float Radius)

Summary:

The distance over the circumference of a circle given two points and radius.

Params:

A:

        Point A.

B:

        Point B.

Radius:

        Radius of the sphere.

Returns:

The distance between two points given a radius.