Class MathUtility
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
valueint
Returns
CountDigits(uint)
Counts the number of digits in an unsigned number.
public static int CountDigits(uint value)
Parameters
valueuint
Returns
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
valuedoubleValue to actually round.
roundintNearest number to round to.
mindoubleAbsolute minimum allowed value. Also acts as the base value to increment by
roundfrom.maxdoubleAbsolute maximum allowed value.
Returns
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
valueintValue to actually round.
roundintNearest number to round to.
minintAbsolute minimum allowed value. Also acts as the base value to increment by
roundfrom.maxintAbsolute maximum allowed value.
Returns
SquaredDistance(in Vector2, in Vector2)
Find square distance between two 2D points.
public static float SquaredDistance(in Vector2 pos1, in Vector2 pos2)
Parameters
pos1Vector2pos2Vector2
Returns
SquaredDistance(in Vector2, in Vector3)
Find square distance between two 2D points.
public static float SquaredDistance(in Vector2 pos1, in Vector3 pos2)
Parameters
pos1Vector2pos2Vector3
Returns
SquaredDistance(Vector3, in Vector3)
Find square distance and optionally ignore the Y axis.
public static float SquaredDistance(Vector3 pos1, in Vector3 pos2)
Parameters
pos1Vector3pos2Vector3
Returns
SquaredDistance(in Vector3, in Vector2)
Find square distance between two 2D points.
public static float SquaredDistance(in Vector3 pos1, in Vector2 pos2)
Parameters
pos1Vector3pos2Vector2
Returns
SquaredDistance(in Vector3, Vector3)
Find square distance and optionally ignore the Y axis.
public static float SquaredDistance(in Vector3 pos1, Vector3 pos2)
Parameters
pos1Vector3pos2Vector3
Returns
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
pos1Vector3pos2Vector3
Returns
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
pos1Vector3pos2Vector3horizontalDistanceOnlybool
Returns
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
pos1Vector3pos2Vector3rangefloat
Returns
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
pos1Vector3pos2Vector3rangefloat
Returns
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
pos1Vector3pos2Vector3rangefloat
Returns
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
pos1Vector3pos2Vector3rangefloat