MW UNITY NAMESPACE








































[Serializable] public struct

MVector


Vector representation of coordinates and points with three-dimensions.



public const float

kEpsilon

Vector floating-point precision.



public readonly MVector

YZ

A new MVector ignoring the X component.



public readonly MVector

XZ

A new MVector ignoring the Y component.



public readonly MVector

XY

A new MVector ignoring the Z component.


CONSTRUCTOR (float U)

Summary:

Construct all components to U.

Params:

U:

        Uniform component.


CONSTRUCTOR (float X, float Y)

Summary:

Construct with X and Y components only.

Params:

X:

        X Component.

Y:

        Y Component.


CONSTRUCTOR (float X, float Y, float Z)

Summary:

Construct an MVector with X, Y, and Z components.

Params:

X:

        X Component.

Y:

        Y Component.

Z:

        Z Component.


CONSTRUCTOR (Vector3 xyz)

Summary:

Construct an MVector with respect to a Vector3.

Params:

xyz:

        The Vector3's Components to set this MVector.


CONSTRUCTOR (Vector2 xy)

Summary:

Construct an MVector with respect to a

Params:

xy:

        The Vector2's Components to set this MVector.



public static readonly MVector

Zero

Short for writing MVector(0).



public static readonly MVector

Right

Short for writing MVector(1, 0, 0).



public static readonly MVector

Up

Short for writing MVector(0, 1, 0).



public static readonly MVector

Forward

Short for writing MVector(0, 0, 1).



public static readonly MVector

One

Short for writing MVector(1).



public static readonly MVector

_2D

1 on XY components. 2D MVector Flag.



public static readonly MVector

_3D

1 on XZ components. 3D MVector Flag.



public static readonly MVector

NaN

NaN on all components.



public static Vector3

V3 (MVector M)

Summary:

Converts an MVector to a Vector3.

Params:

M:

        The MVector to convert.



public static MVector

MV (Vector3 V)

Summary:

Converts a Vector3 to an MVector.

Params:

V:

        The Vector3 to convert.



public static MVector

Normalise ()

Summary:

Normalises V.



public static MVector

Cross ()

Summary:

The vector cross ^ product of Left and Right.



public static float

Dot ()

Summary:

The vector dot | product of Left and Right.

Remarks:

Does not assume Left and Right are normalised.



public static bool

Parallel (MVector Left, MVector Right)

Summary:

Whether left and right are Mathematics.Parallel(MVector, MVector, float) to each other.



[Obsolete] public static MVector

MVectorFromAngle (float Degrees, EDirection Forward)

Summary:

A normalised MVector at Degrees, relative to Forward.

Params:

Degrees:

        The angle offset.

Forward:

        The forward direction.



public static float

Angle (MVector L, MVector R)

Summary:

The angle between two vectors in degrees.

Returns:

An approximation of the angle between L and R in degrees, accurate to +-.1 degrees.



public static float

Distance (MVector Left, MVector Right)

Summary:

The distance between Left and Right.

Params:

Left:

        Source of the distance.

Right:

        Distance from source.



public static float

SqrDistance (MVector Left, MVector Right)

Summary:

Square Euclidean distance between Left and Right.



public static MVector

ClampMagnitude (MVector Vector, float Magnitude)

Summary:

Clamps Vector to a maximum Magnitude.

Params:

Vector:

        The Vector to clamp.

Magnitude:

        The maximum magnitude.

Returns:

The clamped Vector.



public static MVector

ProjectOnNormal (MVector Vector, MVector Normal)

Summary:

Scale Normal to reach the point defined by Vector in 2D space.

Params:

Vector:

        The point to scale Normal by.

Normal:

        The direction to scale towards Vector in 2D space.

Returns:

Vector projected onto Normal.



public static bool

ContainsNaN (MVector V)

Summary:

Checks V's components for NaN.

Params:

V:

        The vector to check.

Returns:

True if V contains NaN.



public static bool

ContainsInf (MVector V)

Summary:

Checks V's components for +- Infinity.

Params:

V:

        The vector to check.

Returns:

True if V contains +- Infinity.



public static bool

ComponentsCheckNaNInf (MVector V)

Summary:

Check V's components for NaN of +-Infinity.

Params:

V:

        The vector to check.

Returns:

True if V contains any illegal components.



public float

SqrMagnitude

The square magnitude of this MVector.



public float

Magnitude

The magnitude of this MVector.



public MVector

Abs

The FMath.Abs(float) of this MVector's components.



public MVector

Normalised

The normalised version of this MVector.



public MVector

Normalise ()

Summary:

Normalises this MVector.



public void

Set ()

Summary:

Sets this MVector's components.



public void

SetMagnitude (float InMagnitude)

Summary:

Sets the magnitude of this MVector.

Params:

InMagnitude:

        The magnitude to set.



public bool

IsNormalised ()

Summary:

Whether this MVector is a unit vector. (If this MVector is Mathematics.IsNormalised(MVector).

Returns:

True if this MVector has a magnitude of one.



public MVector

Mirror (MVector Normal)

Summary:

This MVector's reflection among Normal.

Params:

Normal:

        The normal vector to mirror.



public MVector

RotateVector (float AngleDegrees, MVector Axis)

Summary:

Rotates this MVector at an angle of AngleDegrees around Axis.

Remarks:

While looking in the direction of Axis:
+ Angle is CW. - Angle is CCW.

Params:

AngleDegrees:

        The degrees at which to rotate this MVector.

Axis:

        The axis to rotate this MVector around.



public MRotator

Rotation ()

Summary:

Converts a normalised vector to a Pitch, Yaw rotation.

Remarks:

Roll is zero.

Returns:

An MRotator defining the pitch and yaw of this direction vector.



public void

DirectionAndLength (MVector& Direction, float& Length)

Summary:

The direction and length of this MVector.



public MVector

Projection ()

Summary:

This MVector's projection.



public static MVector

ProjectOnNormal (MVector Normal)

Summary:

Scale Normal to reach the point defined by this vector in 2D space.

Params:

Normal:

        The direction to scale towards this vector in 2D space.

Returns:

This vector projected onto Normal.



public MVector

IgnoreX ()

Summary:

Ignores the X component of this MVector.

Remarks:

Modifies this MVector.

Returns:

This MVector with a zeroed X component.



public MVector

IgnoreY ()

Summary:

Ignores the Y component of this MVector.

Remarks:

Modifies this MVector.

Returns:

This MVector with a zeroed Y component.



public MVector

IgnoreZ ()

Summary:

Ignores the Z component of this MVector.

Remarks:

Modifies this MVector.

Returns:

This MVector with a zeroed Z component.



public MVector

Ignore (EComponentAxis Components)

Summary:

Ignores a set of Components on this MVector.

Params:

Components:

        The vector components to ignore.

Returns:

This MVector zeroed over Components.



public float

Distance (MVector V)

Summary:

Euclidean distance between this MVector and another V.

Params:

V:

        The MVector to find distance.

Returns:

The Euclidean distance between this MVector and V.



public float

SqrDistance (MVector V)

Summary:

The Euclidean distance, but without the square root calculation.

Params:

V:

        The MVector to find square distance.

Returns:

The square distance between this MVector and V.



public void

ClampMagnitude (float ClampedMagnitude)

Summary:

Clamps this Vector's magnitude to ClampedMagnitude.

Params:

ClampedMagnitude:

        The maximum magnitude of this Vector.



public static float operator~

operator~ (MVector M)

Summary:

Get the SqrMagnitude of M.

Params:

M:

        The MVector.

Returns:

The SquMagnitude of M.



public static MVector operator+

operator+ (MVector Left, MVector Right)

Summary:

Adds two MVectors together.

Params:

Left:

        Left-side MVector.

Right:

        Right-side MVector.

Returns:

(MVector Left, MVector Right) => new MVector(Left.X + Right.X, Left.Y + Right.Y, Left.Z + Right.Z)



public static MVector operator+

operator+ (MVector Left, Vector3 Right)

Summary:

Adds a Vector3 to an MVector.

Params:

Left:

        The MVector.

Right:

        The Vector3.

Returns:

(MVector Left, Vector3 Right) => Left + (MVector)Right



public static MVector operator+

operator+ (Vector3 Left, MVector Right)

Summary:

Adds an MVector to a Vector3.

Params:

Left:

        The Vector3.

Right:

        The MVector.

Returns:

(Vector3 Left, MVector Right) => (MVector)Left + Right



public static MVector operator-

operator- (MVector Left, MVector Right)

Summary:

Subtracts two MVectors.

Params:

Left:

        Left-side MVector.

Right:

        Right-side MVector.

Returns:

(MVector Left, MVector Right) => new MVector(Left.X - Right.X, Left.Y - Right.Y, Left.Z - Right.Z)



public static MVector operator-

operator- (MVector V)

Summary:

Negates an MVector.

Params:

V:

        The MVector to negate all components.

Returns:

(MVector V) => V *= -1f



public static MVector operator*

operator* (float S, MVector V)

Summary:

Multiplies an MVector by a scalar on all components.

Params:

S:

        The Scalar to multiply.

V:

        The MVector.

Returns:

(MVector V, float S) => new MVector(V.X * S, V.Y * S, V.Z * S)



public static MVector operator/

operator/ (MVector V, float D)

Summary:

Divides an MVector by a scalar on all components.

Remarks:

If d == 0, this will throw a DivideByZeroException.

Params:

V:

        The MVector.

D:

        The denominator under all components.

Returns:

(MVector V, float D) => float S = 1 / D; return S * V



public static MVector operator^

operator^ (MVector Left, MVector Right)

Summary:

The vector cross ^ product.

Returns:

(MVector Left, MVector Right) => new MVector(Left.Y * Right.Z - Left.Z * Right.Y, Left.Z * Right.X - Left.X * Right.Z, Left.X * Right.Y - Left.Y * Right.X)



public static float operator|

operator| (MVector Left, MVector Right)

Summary:

The vector dot | product.

Remarks:

Does not assume Left and Right are normalised.

Returns:

(MVector Left, MVector Right) => Left.X * Right.X + Left.Y * Right.Y + Left.Z * Right.Z



public static MVector operator>

operator> (MVector From, MVector To)

Summary:

Normalised direction from to.

Returns:

(MVector From, MVector To) => (To - From).Normalised



public static MVector operator<

operator< (MVector From, MVector To)

Summary:

Normalised direction from to.

Returns:

(MVector To, MVector From) => From > To



public static MVector operator>>

operator>> (MVector V, int I)

Summary:

Shifts all components to the right.

Params:

V:

        The MVector to shift.

I:

        The number of times to shift right.

Returns:

X = Y, Y = Z, Z = X.



public static MVector operator<<

operator<< (MVector V, int I)

Summary:

Shifts all components to the left.

Params:

V:

        The MVector to shift.

I:

        The number of times to shift left.

Returns:

X = Z, Y = X, Z = Y.



public static bool operator==

operator= (MVector Left, MVector Right)

Summary:

Compares two MVectors for equality.

Params:

Left:

        Left-side comparison.

Right:

        Right-side comparison.

Returns:

True if the square distance between Left and Right is less than kEpsilon ^ 2.



public static bool operator!=

operator!= (MVector Left, MVector Right)

Summary:

Compares two MVectors for inequality.

Params:

Left:

        Left-side comparison.

Right:

        Right-side comparison.

Returns:

The opposite of operator ==.



public static bool operator true

operator true (MVector M)

Summary:

if the MVector is non-zero.

Params:

M:

        The Vector to check.

Returns:

M != MVector(NaN) && M != MVector.Zero && M.SqrMagnitude > MVector.kEpsilon && !ComponentsCheckNaN(M).



public static bool operator false

operator false (MVector M)

Summary:

if the MVector is zero or considered zero.

Params:

M:

        The Vector to check.

Returns:

M == MVector(NaN) || M == MVector.Zero || M.SqrMagnitude < MVector.kEpsilon || ComponentsCheckNaNInf(M).



public static implicit operator Vector3

MVector -> Vector3 ()

Summary:

Automatic conversion from an MVector to a Vector3.



public static implicit operator Vector2

MVector -> Vector2 ()

Summary:

Automatic conversion from an MVector to a Vector2.

Remarks:

Only the X and Y components are considered. The Z component is ignored.



public static implicit operator MVector

Vector3 -> MVector ()

Summary:

Automatic conversion from a Vector3 to an MVector.



public static implicit operator MVector

Vector2 -> MVector ()

Summary:

Automatic conversion from a Vector2 to an MVector.

Remarks:

The resulting MVector will have a Z equal to zero.



public static implicit operator Color

MVector -> Color ()

Summary:

The Colour representation of this MVector, in 0-255 XYZ/RGB.



public static implicit operator MVector

Color -> MVector ()

Summary:

The MVector representation of a Colour ranged from 0 - 255 RGB/XYZ.



public override int

GetHashCode ()

Summary:

Hash code for use in Maps, Sets, MArrays, etc.

Returns:

GetHashCode() => X.GetHashCode() ^ (Y.GetHashCode() << 2) ^ (Z.GetHashCode() >> 2)



public override string

ToString ()

Summary:

A human-readable MVector.

Returns:

ToString() => "X: " + X + " Y: " + Y + " Z: " + Z



public string

ToString (string Format)

Summary:

A human-readable MVector with formatting.

Params:

Format:

        The format to present float values.

Returns:

A string with X, Y, and Z formatted according to Format.



public string

ToString (string Format, IFormatProvider Provider)

Summary:

A human-readable MVector with formatting and a format provider.

Params:

Format:

        The format to present the float values.

Provider:

        The format provider to present the float values.

Returns:

A string with X, Y, and Z formatting according to Format and Provider.