4 protected const static ref RandomGenerator RANDOM_GENERATOR =
new RandomGenerator();
9 static float fmod(
float dividend,
float divisor)
14 return dividend - Math.Floor(dividend / divisor) * divisor;
25 static float LerpAngle(
float a,
float b,
float t)
27 float dt = fmod(b - a, 360);
31 return fmod(Math.Lerp(a, a + dt, t), 360);
41 static float DeltaAngle(
float a,
float b)
43 return 180 - Math.AbsFloat(fmod(Math.AbsFloat(b - a), 360) - 180);
52 static int IntegerMask(
int x)
64 static float GetDistanceToStop(
float speed,
float deceleration)
68 distance = 0.5 * speed * speed / deceleration;
77 static float GetSpeedToReachDistance(
float distance,
float deceleration)
80 if (
distance > 0 && deceleration > 0)
81 speed = Math.Sqrt(2 *
distance * deceleration);
88 static float GetSpeedToReachDistanceInTime(
float distance,
float deceleration,
float time)
94 float speed = GetSpeedToReachDistance(
distance, deceleration);
95 float averageSpeed =
distance / time;
96 float additionalSpeed = averageSpeed - speed*0.5;
97 speed += additionalSpeed;
107 static RandomGenerator GetMathRandomGenerator()
109 return RANDOM_GENERATOR;