예제 #1
0
        public void Change(float value, float deltaTime, float changePerSecond)
        {
            float dv = value - _value;

            _value += Math.Min(deltaTime * changePerSecond, Math.Abs(dv)) * Math.Sign(dv);
            _value  = CgMath.Clamp(_value, _minValue, _maxValue);
        }
예제 #2
0
        //simple moving average with no weights applied
        public static Func <float, float> Towards(float maxDelta, float startValue = 0.0f)
        {
            float bounds = maxDelta;
            float value  = startValue;

            return((x) =>
            {
                float delta = CgMath.Clamp(x - value, -bounds, bounds);
                value += delta;
                return value;
            });
        }
예제 #3
0
 public Vector2D InRectSpace(Vector2D v)
 {
     return(new Vector2D(
                CgMath.Clamp(v.X - X, 0, Width),
                CgMath.Clamp(v.Y - Y, 0, Height)));
 }