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); }