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); }
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); }
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); }
public static float DistanceBetween(float x1, float y1, float x2, float y2) => FloatMath.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
public float _Clamp(float min, float value, float max) { Asserts.True(min <= max, "Expected min <= max."); return(FloatMath.Max(min, FloatMath.Min(value, max))); }