Table of Contents

Class MathUtility

Namespace
Uncreated.Warfare.Util
Assembly
Uncreated.Warfare.dll
public static class MathUtility
Inheritance
MathUtility
Inherited Members

Methods

CountDigits(int)

Counts the number of digits in a number, not counting the negative sign.

public static int CountDigits(int value)

Parameters

value int

Returns

int

CountDigits(uint)

Counts the number of digits in an unsigned number.

public static int CountDigits(uint value)

Parameters

value uint

Returns

int

RoundNumber(double, int, double, double)

Rounds a number to the nearest round.

public static double RoundNumber(double value, int round, double min, double max)

Parameters

value double

Value to actually round.

round int

Nearest number to round to.

min double

Absolute minimum allowed value. Also acts as the base value to increment by round from.

max double

Absolute maximum allowed value.

Returns

double

RoundNumber(int, int, int, int)

Rounds a number to the nearest round.

public static int RoundNumber(int value, int round, int min, int max)

Parameters

value int

Value to actually round.

round int

Nearest number to round to.

min int

Absolute minimum allowed value. Also acts as the base value to increment by round from.

max int

Absolute maximum allowed value.

Returns

int

SquaredDistance(in Vector2, in Vector2)

Find square distance between two 2D points.

public static float SquaredDistance(in Vector2 pos1, in Vector2 pos2)

Parameters

pos1 Vector2
pos2 Vector2

Returns

float

SquaredDistance(in Vector2, in Vector3)

Find square distance between two 2D points.

public static float SquaredDistance(in Vector2 pos1, in Vector3 pos2)

Parameters

pos1 Vector2
pos2 Vector3

Returns

float

SquaredDistance(Vector3, in Vector3)

Find square distance and optionally ignore the Y axis.

public static float SquaredDistance(Vector3 pos1, in Vector3 pos2)

Parameters

pos1 Vector3
pos2 Vector3

Returns

float

SquaredDistance(in Vector3, in Vector2)

Find square distance between two 2D points.

public static float SquaredDistance(in Vector3 pos1, in Vector2 pos2)

Parameters

pos1 Vector3
pos2 Vector2

Returns

float

SquaredDistance(in Vector3, Vector3)

Find square distance and optionally ignore the Y axis.

public static float SquaredDistance(in Vector3 pos1, Vector3 pos2)

Parameters

pos1 Vector3
pos2 Vector3

Returns

float

SquaredDistance(in Vector3, in Vector3)

Find square distance and optionally ignore the Y axis.

public static float SquaredDistance(in Vector3 pos1, in Vector3 pos2)

Parameters

pos1 Vector3
pos2 Vector3

Returns

float

SquaredDistance(in Vector3, in Vector3, bool)

Find square distance and optionally ignore the Y axis.

public static float SquaredDistance(in Vector3 pos1, in Vector3 pos2, bool horizontalDistanceOnly)

Parameters

pos1 Vector3
pos2 Vector3
horizontalDistanceOnly bool

Returns

float

WithinRange(Vector3, Vector3, float)

Returns true if pos1 and pos2 are less than range units away from each other, otherwise false. Compares using square magnitude for speed.

public static bool WithinRange(Vector3 pos1, Vector3 pos2, float range)

Parameters

pos1 Vector3
pos2 Vector3
range float

Returns

bool

WithinRange(in Vector3, in Vector3, float)

Returns true if pos1 and pos2 are less than range units away from each other, otherwise false. Compares using square magnitude for speed.

public static bool WithinRange(in Vector3 pos1, in Vector3 pos2, float range)

Parameters

pos1 Vector3
pos2 Vector3
range float

Returns

bool

WithinRange2D(Vector3, Vector3, float)

Returns true if pos1 and pos2 are less than range units away from each other, otherwise false. Compares using square magnitude for speed.

public static bool WithinRange2D(Vector3 pos1, Vector3 pos2, float range)

Parameters

pos1 Vector3
pos2 Vector3
range float

Returns

bool

WithinRange2D(in Vector3, in Vector3, float)

Returns true if pos1 and pos2 are less than range units away from each other, otherwise false. Compares using square magnitude for speed.

public static bool WithinRange2D(in Vector3 pos1, in Vector3 pos2, float range)

Parameters

pos1 Vector3
pos2 Vector3
range float

Returns

bool