Esempio n. 1
0
        public float _Wrap(float min, float value, float max)
        {
            Asserts.True(min <= max, "Expected min <= max.");

            var range = max - min;

            var firstPass  = max - FloatMath.Mod(max - value, range);
            var secondPass = min + FloatMath.Mod(firstPass - min, range);

            return(secondPass);
        }
Esempio n. 2
0
        public static float AddTowardsDegrees(
            float degStart,
            float degEnd,
            float inc)
        {
            var diff = TrigMath.DifferenceInDegrees(degEnd, degStart);

            if (FloatMath.Abs(diff) < inc)
            {
                return(degEnd);
            }

            return(degStart + FloatMath.Sign(diff) * inc);
        }
Esempio n. 3
0
        public float _AddTowards(float start, float end, float inc)
        {
            Asserts.True(inc >= 0, "Expected increment to be positive.");

            var range = end - start;

            if (FloatMath.Abs(range) <= inc)
            {
                return(end);
            }

            var sign = FloatMath.Sign(range);

            return(start + sign * inc);
        }
Esempio n. 4
0
 public static float DistanceBetween(float x1, float y1, float x2, float y2)
 => FloatMath.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
Esempio n. 5
0
 public float _Clamp(float min, float value, float max)
 {
     Asserts.True(min <= max, "Expected min <= max.");
     return(FloatMath.Max(min, FloatMath.Min(value, max)));
 }