using System; using System.Numerics; using Godot; namespace SpaceCapture; public static class Utils { /// /// Time-independent damping with exponential-decay. /// /// Current value. /// Target value. /// The proportion of remaining after one second, the rest is . /// Seconds passed since last invocation. /// /// public static T Damp(T current, T target, float smoothing, double deltaTime) where T : IAdditionOperators, ISubtractionOperators, IMultiplyOperators => Lerp(current, target, (float)(1d - Math.Pow(smoothing, deltaTime))); /// public static Godot.Vector2 Damp(Godot.Vector2 current, Godot.Vector2 target, float smoothing, double deltaTime) => current.Lerp(target, (float)(1d - Math.Pow(smoothing, deltaTime))); /// /// public static T Lerp(T from, T to, float weight) where T : IAdditionOperators, ISubtractionOperators, IMultiplyOperators => from + (to - from) * weight; }