public static float ShockWave(float d, float time, float wave_half_width, float wave_speed, float wave_fade, float d_scale) { d *= d_scale; float num = time * wave_speed; float num2 = FMath.Clamp(d - num, -wave_half_width, wave_half_width) / wave_half_width; float num3 = (1f + FMath.Cos(Math.Pi * num2)) * 0.5f; return(num3 * FMath.Exp(-d * wave_fade)); }
private static Func <float, float> SelectBounceCurve(int totalBound, int boundCount, float T0) { float num = AnimationUtility.GetBounceFirstDuration(totalBound) / (float)(boundCount + 1); float bounceOffset = AnimationUtility.GetBounceOffset(totalBound, boundCount, T0); float num2 = FMath.Exp((float)(-(float)boundCount)); float a = -4f * num2 / num / num; float b = 4f * num2 / num; float c = 0f; return(AnimationUtility.XShift(AnimationUtility.QuadCurve(a, b, c), bounceOffset)); }
internal static AnimationInterpolator GetDampedWaveInterpolator(int strength) { strength = (int)FMath.Clamp((float)strength, 0f, 100f); return(AnimationUtility.GetAnimationInterpolator(delegate(float ratio) { if (strength == 0) { return ratio; } return -FMath.Cos(ratio * 3.14159274f * (float)strength * 2f) * FMath.Exp(-ratio * (float)strength) / 2f; })); }
private float zoom_curve(float x, float a, float right_scale) { float num = 1f; if (x > 0f) { num = right_scale; } float num2 = Math.Sign(x); return(1f + num * num2 * (1f - FMath.Exp(-a * FMath.Abs(x / num)))); }
float[] gaussianWeightTable = new float[8]; ///< 8 * 2 = 16 samples table void updateGaussianWeight( float i_dispersion ) { float a_total = 0.0f; for (int i = 0; i < gaussianWeightTable.Length; i++) { float a_pos = 1.0f + 2.0f * (float)i; gaussianWeightTable[i] = (float)FMath.Exp(-0.5f * (float)(a_pos * a_pos) / i_dispersion); a_total += 2.0f * gaussianWeightTable[i]; } // normalize for (int i = 0; i < gaussianWeightTable.Length; i++) { gaussianWeightTable[i] /= a_total; } }
internal static AnimationInterpolator GetSpringInterpolator(int strength) { if (strength > 0) { strength = Math.Min(100, strength); float startupTime = 0.4f / (float)strength; float cycleTime = (1f - startupTime) / (float)strength; float angularFrequency = 6.28318548f / cycleTime; Func <float, float> ratioConverter = delegate(float t) { if (t >= startupTime) { return(0.7f + 0.3f * FMath.Exp(-(t - startupTime) / cycleTime) * FMath.Cos(angularFrequency * (t - startupTime))); } return(FMath.Sin(t * 3.14159274f / 2f / startupTime)); }; return(AnimationUtility.GetAnimationInterpolator(ratioConverter)); } return(new AnimationInterpolator(AnimationUtility.LinearInterpolator)); }
private static Func <float, float> SelectBounceInCurve(int totalBound, int boundCount, float T0) { float num = T0 / (float)(boundCount + 1); float bounceOffset = AnimationUtility.GetBounceOffset(totalBound, boundCount, T0); float a; float b; float c; if (boundCount == 0) { a = 1f / num / num; b = 0f; c = 0f; } else { float num2 = FMath.Exp((float)(-(float)boundCount)); a = 4f * num2 / num / num; b = -4f * num2 / num; c = 1f; } return(AnimationUtility.XShift(AnimationUtility.QuadCurve(a, b, c), bounceOffset)); }
public static float Impulse(float x, float b) { float num = b * x; return(num * FMath.Exp(1f - num)); }
public static float ExpEaseOut(float x, float a) { return((1f - FMath.Exp(-x * a)) / (1f - FMath.Exp(-a))); }