Class MathematicalCalculator
- Namespace
- CodeBase
- Assembly
- 4Experience.CodeBase.Core.Runtime.dll
A helper class contains many independent and small methods with various mathematical functions. Mathematical functions mainly related to probability and randomization (System.Random and Unity Random).
public static class MathematicalCalculator
- Inheritance
-
MathematicalCalculator
Constructors
MathematicalCalculator()
The static constructor initializes the randomization system based on System.Random.
private static MathematicalCalculator()
Properties
CurrentSystemRandom
private static Random CurrentSystemRandom { get; set; }
Property Value
Methods
GetInvertMultiplier(bool)
Returns -1 if isInvert equals true and 1 if isInvert equals false.
public static int GetInvertMultiplier(bool isInvert)
Parameters
isInvertbool
Returns
GetNormalizedProbability()
Returns a normalized random float number between 0.0 and 1.0. Based on Unity Random.
public static float GetNormalizedProbability()
Returns
IsProbabilityLargerThanNormalizedValue(float)
Get random number if drawn number is greater than value return true. Value and drawn number are normalized.
public static bool IsProbabilityLargerThanNormalizedValue(float normalizedValue)
Parameters
normalizedValuefloat
Returns
IsProbabilityLargerThanValue(float, float, float)
Get random number between minValue and maxValue. If drawn number is greater than value return true.
public static bool IsProbabilityLargerThanValue(float value, float minValue, float maxValue)
Parameters
Returns
IsSumEven(int, int)
Returns true if the sum of two numbers is even.
public static bool IsSumEven(int x, int y)
Parameters
Returns
SetAllRandomGeneratorsSeed(int)
Sets one seed for Unity Random and System.Random. The seed is responsible for the initialization of the engine that generates random numbers. For the same seed, the random results will be the same each time with the same drawing conditions.
public static void SetAllRandomGeneratorsSeed(int seed)
Parameters
seedint
SetSystemRandomSeed(int)
Sets the seed for System.Random. The seed is responsible for the initialization of the engine that generates random numbers. For the same seed, the random results will be the same each time with the same drawing conditions.
public static void SetSystemRandomSeed(int seed)
Parameters
seedint
SetUnityRandomSeed(int)
Sets the seed for Unity Random. The seed is responsible for the initialization of the engine that generates random numbers. For the same seed, the random results will be the same each time with the same drawing conditions.
public static void SetUnityRandomSeed(int seed)
Parameters
seedint
SystemRandom(int, int)
Returns a random integer number between min [inclusive] and max [exclusive].
public static int SystemRandom(int min, int max)
Parameters
Returns
SystemRandom(float, float)
Returns a random float number between and min [inclusive] and max [exclusive].
public static float SystemRandom(float min, float max)
Parameters
Returns
SystemRandom(Vector2)
Returns a random float number between and min [inclusive] and max [exclusive].
public static float SystemRandom(Vector2 range)
Parameters
rangeVector2
Returns
UnityRandom(int, int)
Returns a random integer number between min [inclusive] and max [exclusive].
public static int UnityRandom(int min, int max)
Parameters
Returns
UnityRandom(float, float)
Returns a random float number between and min [inclusive] and max [inclusive].
public static float UnityRandom(float min, float max)
Parameters
Returns
UnityRandom(Vector2)
Returns a random float number between and min [inclusive] and max [inclusive].
public static float UnityRandom(Vector2 range)
Parameters
rangeVector2