diff --git a/AssemblyInfo.cs b/AssemblyInfo.cs
index c1d06ae..9a4bdff 100644
--- a/AssemblyInfo.cs
+++ b/AssemblyInfo.cs
@@ -5,6 +5,7 @@
//[assembly: Preserve]
//[assembly: InternalsVisibleTo("SatorImaging.Tests.UnityFundamentals")]
+[assembly: InternalsVisibleTo("ExpectedValueGenerator")]
/* ===== SPECIAL ACCESSIBILITY ===== */
diff --git a/Burst/Mathematics/EasingDouble.cs b/Burst/Mathematics/EasingDouble.cs
index 2ea98a1..577bf96 100644
--- a/Burst/Mathematics/EasingDouble.cs
+++ b/Burst/Mathematics/EasingDouble.cs
@@ -60,45 +60,63 @@ public struct EasingDouble
{
/* Quad ================================================================ */
/// Quadratic easing (Entering).
- public static PRECISION QuadIn(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : x * x); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION QuadIn(PRECISION x) => QuadIn_Raw(x);
/// Quadratic easing (Exiting).
- public static PRECISION QuadOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : 1.0 - ((1.0 - x) * (1.0 - x))); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION QuadOut(PRECISION x) => QuadOut_Raw(x);
/// Quadratic easing (Entering and Exiting).
- public static PRECISION QuadInOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : x < 0.5 ? 2.0 * x * x : 1.0 - (((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * 0.5)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
+ public static PRECISION QuadInOut(PRECISION x) => QuadInOut_Raw(x);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION QuadIn_Raw(PRECISION x) => x * x;
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION QuadOut_Raw(PRECISION x) => 1.0 - ((1.0 - x) * (1.0 - x));
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION QuadInOut_Raw(PRECISION x) => x < 0.5 ? 2.0 * x * x : 1.0 - (((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * 0.5);
/* Cubic ================================================================ */
/// Cubic easing (Entering).
- public static PRECISION CubicIn(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : x * x * x); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION CubicIn(PRECISION x) => CubicIn_Raw(x);
/// Cubic easing (Exiting).
- public static PRECISION CubicOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : 1.0 - ((1.0 - x) * (1.0 - x) * (1.0 - x))); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION CubicOut(PRECISION x) => CubicOut_Raw(x);
/// Cubic easing (Entering and Exiting).
- public static PRECISION CubicInOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : x < 0.5 ? 4.0 * x * x * x : 1.0 - (((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * 0.5)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
+ public static PRECISION CubicInOut(PRECISION x) => CubicInOut_Raw(x);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION CubicIn_Raw(PRECISION x) => x * x * x;
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION CubicOut_Raw(PRECISION x) => 1.0 - ((1.0 - x) * (1.0 - x) * (1.0 - x));
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION CubicInOut_Raw(PRECISION x) => x < 0.5 ? 4.0 * x * x * x : 1.0 - (((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * 0.5);
/* Quart ================================================================ */
/// Quartic easing (Entering).
- public static PRECISION QuartIn(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : x * x * x * x); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION QuartIn(PRECISION x) => QuartIn_Raw(x);
/// Quartic easing (Exiting).
- public static PRECISION QuartOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : 1.0 - ((1.0 - x) * (1.0 - x) * (1.0 - x) * (1.0 - x))); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION QuartOut(PRECISION x) => QuartOut_Raw(x);
/// Quartic easing (Entering and Exiting).
- public static PRECISION QuartInOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : x < 0.5 ? 8.0 * x * x * x * x : 1.0 - (((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * 0.5)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
+ public static PRECISION QuartInOut(PRECISION x) => QuartInOut_Raw(x);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION QuartIn_Raw(PRECISION x) => x * x * x * x;
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION QuartOut_Raw(PRECISION x) => 1.0 - ((1.0 - x) * (1.0 - x) * (1.0 - x) * (1.0 - x));
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION QuartInOut_Raw(PRECISION x) => x < 0.5 ? 8.0 * x * x * x * x : 1.0 - (((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * 0.5);
/* Quint ================================================================ */
/// Quintic easing (Entering).
- public static PRECISION QuintIn(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : x * x * x * x * x); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION QuintIn(PRECISION x) => QuintIn_Raw(x);
/// Quintic easing (Exiting).
- public static PRECISION QuintOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : 1.0 - ((1.0 - x) * (1.0 - x) * (1.0 - x) * (1.0 - x) * (1.0 - x))); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION QuintOut(PRECISION x) => QuintOut_Raw(x);
/// Quintic easing (Entering and Exiting).
- public static PRECISION QuintInOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : x < 0.5 ? 16.0 * x * x * x * x * x : 1.0 - (((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * 0.5)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
+ public static PRECISION QuintInOut(PRECISION x) => QuintInOut_Raw(x);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION QuintIn_Raw(PRECISION x) => x * x * x * x * x;
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION QuintOut_Raw(PRECISION x) => 1.0 - ((1.0 - x) * (1.0 - x) * (1.0 - x) * (1.0 - x) * (1.0 - x));
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION QuintInOut_Raw(PRECISION x) => x < 0.5 ? 16.0 * x * x * x * x * x : 1.0 - (((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * ((-2.0 * x) + 2.0) * 0.5);
/* Sine ================================================================ */
+ /// Sinusoidal easing (Entering).
+ public static PRECISION SineIn(PRECISION x) => SineIn_Raw(x);
+ /// Sinusoidal easing (Exiting).
+ public static PRECISION SineOut(PRECISION x) => SineOut_Raw(x);
+ /// Sinusoidal easing (Entering and Exiting).
+ public static PRECISION SineInOut(PRECISION x) => SineInOut_Raw(x);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION SineIn_Raw(PRECISION x) => 1.0 - Sin5((1.0 - x) * SYSMATH.PI * 0.5);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION SineOut_Raw(PRECISION x) => Sin5(x * SYSMATH.PI * 0.5);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION SineInOut_Raw(PRECISION x) => (1.0 - Sin5((0.5 - x) * SYSMATH.PI)) * 0.5;
// x5 faster but low quality especially for Elastic (in slo mo, less motion continuity)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -114,29 +132,31 @@ private static PRECISION Sin5(PRECISION t)
return t - (t * t * t * inv6) + (t * t * t * t * t * invC);
}
- /// Sinusoidal easing (Entering).
- public static PRECISION SineIn(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : 1.0 - Sin5((1.0 - x) * SYSMATH.PI * 0.5)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
- /// Sinusoidal easing (Exiting).
- public static PRECISION SineOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : Sin5(x * SYSMATH.PI * 0.5)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
- /// Sinusoidal easing (Entering and Exiting).
- public static PRECISION SineInOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : (1.0 - Sin5((0.5 - x) * SYSMATH.PI)) * 0.5); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
/* Expo ================================================================ */
-
- private const PRECISION ln_2 = 0.6931471805599453;
-
/// Exponential easing (Entering).
- public static PRECISION ExpoIn(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : Math.exp(((10.0 * x) - 10.0) * ln_2)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION ExpoIn(PRECISION x) => ExpoIn_Raw(x);
/// Exponential easing (Exiting).
- public static PRECISION ExpoOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : 1.0 - Math.exp((-10.0 * x) * ln_2)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION ExpoOut(PRECISION x) => ExpoOut_Raw(x);
/// Exponential easing (Entering and Exiting).
- public static PRECISION ExpoInOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : x < 0.5 ? Math.exp(((20.0 * x) - 10.0) * ln_2) * 0.5 : (2.0 - Math.exp((10.0 - (20.0 * x)) * ln_2)) * 0.5); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
+ public static PRECISION ExpoInOut(PRECISION x) => ExpoInOut_Raw(x);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION ExpoIn_Raw(PRECISION x) => x <= 0.0 ? 0.0 : Math.exp(((10.0 * x) - 10.0) * ln_2);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION ExpoOut_Raw(PRECISION x) => x >= 1.0 ? 1.0 : 1.0 - Math.exp((-10.0 * x) * ln_2);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION ExpoInOut_Raw(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : x < 0.5 ? Math.exp(((20.0 * x) - 10.0) * ln_2) * 0.5 : (2.0 - Math.exp((10.0 - (20.0 * x)) * ln_2)) * 0.5);
+
+ private const PRECISION ln_2 = 0.6931471805599453;
/* Circ ================================================================ */
+ /// Circular easing (Entering).
+ public static PRECISION CircIn(PRECISION x) => CircIn_Raw(x);
+ /// Circular easing (Exiting).
+ public static PRECISION CircOut(PRECISION x) => CircOut_Raw(x);
+ /// Circular easing (Entering and Exiting).
+ public static PRECISION CircInOut(PRECISION x) => CircInOut_Raw(x);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION CircIn_Raw(PRECISION x) => 1.0 - FastSqrt(1.0 - (x * x));
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION CircOut_Raw(PRECISION x) => FastSqrt(1.0 - ((x - 1.0) * (x - 1.0)));
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION CircInOut_Raw(PRECISION x) => x < 0.5 ? (1.0 - FastSqrt(1.0 - ((2.0 * x) * (2.0 * x)))) * 0.5 : (FastSqrt(1.0 - ((2.0 - (2.0 * x)) * (2.0 - (2.0 * x)))) + 1.0) * 0.5;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static PRECISION FastSqrt(PRECISION x)
@@ -155,44 +175,47 @@ private static PRECISION FastSqrt(PRECISION x)
return x <= 0.0 ? 0.0 : x * y;
}
- /// Circular easing (Entering).
- public static PRECISION CircIn(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : 1.0 - FastSqrt(1.0 - (x * x))); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
- /// Circular easing (Exiting).
- public static PRECISION CircOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : FastSqrt(1.0 - ((x - 1.0) * (x - 1.0)))); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
- /// Circular easing (Entering and Exiting).
- public static PRECISION CircInOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : x < 0.5 ? (1.0 - FastSqrt(1.0 - ((2.0 * x) * (2.0 * x)))) * 0.5 : (FastSqrt(1.0 - ((2.0 - (2.0 * x)) * (2.0 - (2.0 * x)))) + 1.0) * 0.5); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
/* Back ================================================================ */
-
- private const PRECISION c1 = 1.70158;
- private const PRECISION c2 = c1 * 1.525;
-
/// Back easing (overshooting) (Entering).
- public static PRECISION BackIn(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : ((c1 + 1.0) * x * x * x) - (c1 * x * x)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION BackIn(PRECISION x) => BackIn_Raw(x);
/// Back easing (overshooting) (Exiting).
- public static PRECISION BackOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : 1.0 + ((c1 + 1.0) * (x - 1.0) * (x - 1.0) * (x - 1.0)) + (c1 * (x - 1.0) * (x - 1.0))); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION BackOut(PRECISION x) => BackOut_Raw(x);
/// Back easing (overshooting) (Entering and Exiting).
- public static PRECISION BackInOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : x < 0.5 ? ((2.0 * x) * (2.0 * x) * (((c2 + 1.0) * (2.0 * x)) - c2)) * 0.5 : (((2.0 * x - 2.0) * (2.0 * x - 2.0) * (((c2 + 1.0) * (2.0 * x - 2.0)) + c2)) + 2.0) * 0.5); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
+ public static PRECISION BackInOut(PRECISION x) => BackInOut_Raw(x);
- /* Elastic ================================================================ */
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION BackIn_Raw(PRECISION x) => ((c1 + 1.0) * x * x * x) - (c1 * x * x);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION BackOut_Raw(PRECISION x) => 1.0 + ((c1 + 1.0) * (x - 1.0) * (x - 1.0) * (x - 1.0)) + (c1 * (x - 1.0) * (x - 1.0));
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION BackInOut_Raw(PRECISION x) => x < 0.5 ? ((2.0 * x) * (2.0 * x) * (((c2 + 1.0) * (2.0 * x)) - c2)) * 0.5 : (((2.0 * x - 2.0) * (2.0 * x - 2.0) * (((c2 + 1.0) * (2.0 * x - 2.0)) + c2)) + 2.0) * 0.5;
- private const PRECISION e_c4 = 2.0 * SYSMATH.PI / 3.0;
- private const PRECISION e_c5 = 2.0 * SYSMATH.PI / 4.5;
+ private const PRECISION c1 = 1.70158;
+ private const PRECISION c2 = c1 * 1.525;
+ /* Elastic ================================================================ */
/// Elastic easing (oscillating spring) (Entering).
- public static PRECISION ElasticIn(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : -Math.exp(((10.0 * x) - 10.0) * ln_2) * Math.sin(((10.0 * x) - 10.75) * e_c4)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION ElasticIn(PRECISION x) => ElasticIn_Raw(x);
/// Elastic easing (oscillating spring) (Exiting).
- public static PRECISION ElasticOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : (Math.exp((-10.0 * x) * ln_2) * Math.sin(((10.0 * x) - 0.75) * e_c4)) + 1.0); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION ElasticOut(PRECISION x) => ElasticOut_Raw(x);
/// Elastic easing (oscillating spring) (Entering and Exiting).
- public static PRECISION ElasticInOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : x < 0.5 ? -Math.exp(((20.0 * x) - 10.0) * ln_2) * Math.sin(((20.0 * x) - 11.125) * e_c5) * 0.5 : (Math.exp((10.0 - (20.0 * x)) * ln_2) * Math.sin(((20.0 * x) - 11.125) * e_c5) * 0.5) + 1.0); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
+ public static PRECISION ElasticInOut(PRECISION x) => ElasticInOut_Raw(x);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION ElasticIn_Raw(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : -Math.exp(((10.0 * x) - 10.0) * ln_2) * Math.sin(((10.0 * x) - 10.75) * e_c4));
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION ElasticOut_Raw(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : (Math.exp((-10.0 * x) * ln_2) * Math.sin(((10.0 * x) - 0.75) * e_c4)) + 1.0);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION ElasticInOut_Raw(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : x < 0.5 ? -Math.exp(((20.0 * x) - 10.0) * ln_2) * Math.sin(((20.0 * x) - 11.125) * e_c5) * 0.5 : (Math.exp((10.0 - (20.0 * x)) * ln_2) * Math.sin(((20.0 * x) - 11.125) * e_c5) * 0.5) + 1.0);
+
+ private const PRECISION e_c4 = 2.0 * SYSMATH.PI / 3.0;
+ private const PRECISION e_c5 = 2.0 * SYSMATH.PI / 4.5;
/* Bounce ================================================================ */
+ /// Bounce easing (simulated gravity/collision) (Entering).
+ public static PRECISION BounceIn(PRECISION x) => BounceIn_Raw(x);
+ /// Bounce easing (simulated gravity/collision) (Exiting).
+ public static PRECISION BounceOut(PRECISION x) => BounceOut_Raw(x);
+ /// Bounce easing (simulated gravity/collision) (Entering and Exiting).
+ public static PRECISION BounceInOut(PRECISION x) => BounceInOut_Raw(x);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION BounceIn_Raw(PRECISION x) => 1.0 - BounceOut_Impl(1.0 - x);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION BounceOut_Raw(PRECISION x) => BounceOut_Impl(x);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION BounceInOut_Raw(PRECISION x) => x < 0.5 ? (1.0 - BounceOut_Impl(1.0 - (2.0 * x))) * 0.5 : (1.0 + BounceOut_Impl((2.0 * x) - 1.0)) * 0.5;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static PRECISION BounceOut_Impl(PRECISION x)
@@ -204,14 +227,5 @@ private static PRECISION BounceOut_Impl(PRECISION x)
x < 2.5 * d1_inv ? (n1 * (x - (2.25 * d1_inv)) * (x - (2.25 * d1_inv))) + 0.9375 :
(n1 * (x - (2.625 * d1_inv)) * (x - (2.625 * d1_inv))) + 0.984375;
}
-
- /// Bounce easing (simulated gravity/collision) (Entering).
- public static PRECISION BounceIn(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : 1.0 - BounceOut_Impl(1.0 - x)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
- /// Bounce easing (simulated gravity/collision) (Exiting).
- public static PRECISION BounceOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : BounceOut_Impl(x)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
- /// Bounce easing (simulated gravity/collision) (Entering and Exiting).
- public static PRECISION BounceInOut(PRECISION x) => x <= 0.0 ? 0.0 : (x >= 1.0 ? 1.0 : x < 0.5 ? (1.0 - BounceOut_Impl(1.0 - (2.0 * x))) * 0.5 : (1.0 + BounceOut_Impl((2.0 * x) - 1.0)) * 0.5); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
}
}
diff --git a/Burst/Mathematics/EasingFloat.cs b/Burst/Mathematics/EasingFloat.cs
index 6654518..437efb8 100644
--- a/Burst/Mathematics/EasingFloat.cs
+++ b/Burst/Mathematics/EasingFloat.cs
@@ -64,45 +64,63 @@ public struct EasingFloat
{
/* Quad ================================================================ */
/// Quadratic easing (Entering).
- public static PRECISION QuadIn(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : x * x); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION QuadIn(PRECISION x) => QuadIn_Raw(x);
/// Quadratic easing (Exiting).
- public static PRECISION QuadOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : 1.0f - ((1.0f - x) * (1.0f - x))); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION QuadOut(PRECISION x) => QuadOut_Raw(x);
/// Quadratic easing (Entering and Exiting).
- public static PRECISION QuadInOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : x < 0.5f ? 2.0f * x * x : 1.0f - (((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * 0.5f)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
+ public static PRECISION QuadInOut(PRECISION x) => QuadInOut_Raw(x);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION QuadIn_Raw(PRECISION x) => x * x;
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION QuadOut_Raw(PRECISION x) => 1.0f - ((1.0f - x) * (1.0f - x));
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION QuadInOut_Raw(PRECISION x) => x < 0.5f ? 2.0f * x * x : 1.0f - (((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * 0.5f);
/* Cubic ================================================================ */
/// Cubic easing (Entering).
- public static PRECISION CubicIn(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : x * x * x); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION CubicIn(PRECISION x) => CubicIn_Raw(x);
/// Cubic easing (Exiting).
- public static PRECISION CubicOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : 1.0f - ((1.0f - x) * (1.0f - x) * (1.0f - x))); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION CubicOut(PRECISION x) => CubicOut_Raw(x);
/// Cubic easing (Entering and Exiting).
- public static PRECISION CubicInOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : x < 0.5f ? 4.0f * x * x * x : 1.0f - (((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * 0.5f)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
+ public static PRECISION CubicInOut(PRECISION x) => CubicInOut_Raw(x);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION CubicIn_Raw(PRECISION x) => x * x * x;
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION CubicOut_Raw(PRECISION x) => 1.0f - ((1.0f - x) * (1.0f - x) * (1.0f - x));
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION CubicInOut_Raw(PRECISION x) => x < 0.5f ? 4.0f * x * x * x : 1.0f - (((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * 0.5f);
/* Quart ================================================================ */
/// Quartic easing (Entering).
- public static PRECISION QuartIn(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : x * x * x * x); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION QuartIn(PRECISION x) => QuartIn_Raw(x);
/// Quartic easing (Exiting).
- public static PRECISION QuartOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : 1.0f - ((1.0f - x) * (1.0f - x) * (1.0f - x) * (1.0f - x))); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION QuartOut(PRECISION x) => QuartOut_Raw(x);
/// Quartic easing (Entering and Exiting).
- public static PRECISION QuartInOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : x < 0.5f ? 8.0f * x * x * x * x : 1.0f - (((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * 0.5f)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
+ public static PRECISION QuartInOut(PRECISION x) => QuartInOut_Raw(x);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION QuartIn_Raw(PRECISION x) => x * x * x * x;
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION QuartOut_Raw(PRECISION x) => 1.0f - ((1.0f - x) * (1.0f - x) * (1.0f - x) * (1.0f - x));
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION QuartInOut_Raw(PRECISION x) => x < 0.5f ? 8.0f * x * x * x * x : 1.0f - (((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * 0.5f);
/* Quint ================================================================ */
/// Quintic easing (Entering).
- public static PRECISION QuintIn(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : x * x * x * x * x); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION QuintIn(PRECISION x) => QuintIn_Raw(x);
/// Quintic easing (Exiting).
- public static PRECISION QuintOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : 1.0f - ((1.0f - x) * (1.0f - x) * (1.0f - x) * (1.0f - x) * (1.0f - x))); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION QuintOut(PRECISION x) => QuintOut_Raw(x);
/// Quintic easing (Entering and Exiting).
- public static PRECISION QuintInOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : x < 0.5f ? 16.0f * x * x * x * x * x : 1.0f - (((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * 0.5f)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
+ public static PRECISION QuintInOut(PRECISION x) => QuintInOut_Raw(x);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION QuintIn_Raw(PRECISION x) => x * x * x * x * x;
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION QuintOut_Raw(PRECISION x) => 1.0f - ((1.0f - x) * (1.0f - x) * (1.0f - x) * (1.0f - x) * (1.0f - x));
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION QuintInOut_Raw(PRECISION x) => x < 0.5f ? 16.0f * x * x * x * x * x : 1.0f - (((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * ((-2.0f * x) + 2.0f) * 0.5f);
/* Sine ================================================================ */
+ /// Sinusoidal easing (Entering).
+ public static PRECISION SineIn(PRECISION x) => SineIn_Raw(x);
+ /// Sinusoidal easing (Exiting).
+ public static PRECISION SineOut(PRECISION x) => SineOut_Raw(x);
+ /// Sinusoidal easing (Entering and Exiting).
+ public static PRECISION SineInOut(PRECISION x) => SineInOut_Raw(x);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION SineIn_Raw(PRECISION x) => 1.0f - Sin5((1.0f - x) * SYSMATH.PI * 0.5f);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION SineOut_Raw(PRECISION x) => Sin5(x * SYSMATH.PI * 0.5f);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION SineInOut_Raw(PRECISION x) => (1.0f - Sin5((0.5f - x) * SYSMATH.PI)) * 0.5f;
// x5 faster but low quality especially for Elastic (in slo mo, less motion continuity)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -118,29 +136,31 @@ private static PRECISION Sin5(PRECISION t)
return t - (t * t * t * inv6) + (t * t * t * t * t * invC);
}
- /// Sinusoidal easing (Entering).
- public static PRECISION SineIn(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : 1.0f - Sin5((1.0f - x) * SYSMATH.PI * 0.5f)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
- /// Sinusoidal easing (Exiting).
- public static PRECISION SineOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : Sin5(x * SYSMATH.PI * 0.5f)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
- /// Sinusoidal easing (Entering and Exiting).
- public static PRECISION SineInOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : (1.0f - Sin5((0.5f - x) * SYSMATH.PI)) * 0.5f); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
/* Expo ================================================================ */
-
- private const PRECISION ln_2 = 0.6931471805599453f;
-
/// Exponential easing (Entering).
- public static PRECISION ExpoIn(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : Math.exp(((10.0f * x) - 10.0f) * ln_2)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION ExpoIn(PRECISION x) => ExpoIn_Raw(x);
/// Exponential easing (Exiting).
- public static PRECISION ExpoOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : 1.0f - Math.exp((-10.0f * x) * ln_2)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION ExpoOut(PRECISION x) => ExpoOut_Raw(x);
/// Exponential easing (Entering and Exiting).
- public static PRECISION ExpoInOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : x < 0.5f ? Math.exp(((20.0f * x) - 10.0f) * ln_2) * 0.5f : (2.0f - Math.exp((10.0f - (20.0f * x)) * ln_2)) * 0.5f); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
+ public static PRECISION ExpoInOut(PRECISION x) => ExpoInOut_Raw(x);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION ExpoIn_Raw(PRECISION x) => x <= 0.0f ? 0.0f : Math.exp(((10.0f * x) - 10.0f) * ln_2);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION ExpoOut_Raw(PRECISION x) => x >= 1.0f ? 1.0f : 1.0f - Math.exp((-10.0f * x) * ln_2);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION ExpoInOut_Raw(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : x < 0.5f ? Math.exp(((20.0f * x) - 10.0f) * ln_2) * 0.5f : (2.0f - Math.exp((10.0f - (20.0f * x)) * ln_2)) * 0.5f);
+
+ private const PRECISION ln_2 = 0.6931471805599453f;
/* Circ ================================================================ */
+ /// Circular easing (Entering).
+ public static PRECISION CircIn(PRECISION x) => CircIn_Raw(x);
+ /// Circular easing (Exiting).
+ public static PRECISION CircOut(PRECISION x) => CircOut_Raw(x);
+ /// Circular easing (Entering and Exiting).
+ public static PRECISION CircInOut(PRECISION x) => CircInOut_Raw(x);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION CircIn_Raw(PRECISION x) => 1.0f - FastSqrt(1.0f - (x * x));
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION CircOut_Raw(PRECISION x) => FastSqrt(1.0f - ((x - 1.0f) * (x - 1.0f)));
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION CircInOut_Raw(PRECISION x) => x < 0.5f ? (1.0f - FastSqrt(1.0f - ((2.0f * x) * (2.0f * x)))) * 0.5f : (FastSqrt(1.0f - ((2.0f - (2.0f * x)) * (2.0f - (2.0f * x)))) + 1.0f) * 0.5f;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static PRECISION FastSqrt(PRECISION x)
@@ -159,44 +179,47 @@ private static PRECISION FastSqrt(PRECISION x)
return x <= 0.0f ? 0.0f : x * y;
}
- /// Circular easing (Entering).
- public static PRECISION CircIn(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : 1.0f - FastSqrt(1.0f - (x * x))); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
- /// Circular easing (Exiting).
- public static PRECISION CircOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : FastSqrt(1.0f - ((x - 1.0f) * (x - 1.0f)))); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
- /// Circular easing (Entering and Exiting).
- public static PRECISION CircInOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : x < 0.5f ? (1.0f - FastSqrt(1.0f - ((2.0f * x) * (2.0f * x)))) * 0.5f : (FastSqrt(1.0f - ((2.0f - (2.0f * x)) * (2.0f - (2.0f * x)))) + 1.0f) * 0.5f); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
/* Back ================================================================ */
-
- private const PRECISION c1 = 1.70158f;
- private const PRECISION c2 = c1 * 1.525f;
-
/// Back easing (overshooting) (Entering).
- public static PRECISION BackIn(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : ((c1 + 1.0f) * x * x * x) - (c1 * x * x)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION BackIn(PRECISION x) => BackIn_Raw(x);
/// Back easing (overshooting) (Exiting).
- public static PRECISION BackOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : 1.0f + ((c1 + 1.0f) * (x - 1.0f) * (x - 1.0f) * (x - 1.0f)) + (c1 * (x - 1.0f) * (x - 1.0f))); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION BackOut(PRECISION x) => BackOut_Raw(x);
/// Back easing (overshooting) (Entering and Exiting).
- public static PRECISION BackInOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : x < 0.5f ? ((2.0f * x) * (2.0f * x) * (((c2 + 1.0f) * (2.0f * x)) - c2)) * 0.5f : (((2.0f * x - 2.0f) * (2.0f * x - 2.0f) * (((c2 + 1.0f) * (2.0f * x - 2.0f)) + c2)) + 2.0f) * 0.5f); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
+ public static PRECISION BackInOut(PRECISION x) => BackInOut_Raw(x);
- /* Elastic ================================================================ */
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION BackIn_Raw(PRECISION x) => ((c1 + 1.0f) * x * x * x) - (c1 * x * x);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION BackOut_Raw(PRECISION x) => 1.0f + ((c1 + 1.0f) * (x - 1.0f) * (x - 1.0f) * (x - 1.0f)) + (c1 * (x - 1.0f) * (x - 1.0f));
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION BackInOut_Raw(PRECISION x) => x < 0.5f ? ((2.0f * x) * (2.0f * x) * (((c2 + 1.0f) * (2.0f * x)) - c2)) * 0.5f : (((2.0f * x - 2.0f) * (2.0f * x - 2.0f) * (((c2 + 1.0f) * (2.0f * x - 2.0f)) + c2)) + 2.0f) * 0.5f;
- private const PRECISION e_c4 = 2.0f * SYSMATH.PI / 3.0f;
- private const PRECISION e_c5 = 2.0f * SYSMATH.PI / 4.5f;
+ private const PRECISION c1 = 1.70158f;
+ private const PRECISION c2 = c1 * 1.525f;
+ /* Elastic ================================================================ */
/// Elastic easing (oscillating spring) (Entering).
- public static PRECISION ElasticIn(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : -Math.exp(((10.0f * x) - 10.0f) * ln_2) * Math.sin(((10.0f * x) - 10.75f) * e_c4)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION ElasticIn(PRECISION x) => ElasticIn_Raw(x);
/// Elastic easing (oscillating spring) (Exiting).
- public static PRECISION ElasticOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : (Math.exp((-10.0f * x) * ln_2) * Math.sin(((10.0f * x) - 0.75f) * e_c4)) + 1.0f); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
+ public static PRECISION ElasticOut(PRECISION x) => ElasticOut_Raw(x);
/// Elastic easing (oscillating spring) (Entering and Exiting).
- public static PRECISION ElasticInOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : x < 0.5f ? -Math.exp(((20.0f * x) - 10.0f) * ln_2) * Math.sin(((20.0f * x) - 11.125f) * e_c5) * 0.5f : (Math.exp((10.0f - (20.0f * x)) * ln_2) * Math.sin(((20.0f * x) - 11.125f) * e_c5) * 0.5f) + 1.0f); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
+ public static PRECISION ElasticInOut(PRECISION x) => ElasticInOut_Raw(x);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION ElasticIn_Raw(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : -Math.exp(((10.0f * x) - 10.0f) * ln_2) * Math.sin(((10.0f * x) - 10.75f) * e_c4));
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION ElasticOut_Raw(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : (Math.exp((-10.0f * x) * ln_2) * Math.sin(((10.0f * x) - 0.75f) * e_c4)) + 1.0f);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION ElasticInOut_Raw(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : x < 0.5f ? -Math.exp(((20.0f * x) - 10.0f) * ln_2) * Math.sin(((20.0f * x) - 11.125f) * e_c5) * 0.5f : (Math.exp((10.0f - (20.0f * x)) * ln_2) * Math.sin(((20.0f * x) - 11.125f) * e_c5) * 0.5f) + 1.0f);
+
+ private const PRECISION e_c4 = 2.0f * SYSMATH.PI / 3.0f;
+ private const PRECISION e_c5 = 2.0f * SYSMATH.PI / 4.5f;
/* Bounce ================================================================ */
+ /// Bounce easing (simulated gravity/collision) (Entering).
+ public static PRECISION BounceIn(PRECISION x) => BounceIn_Raw(x);
+ /// Bounce easing (simulated gravity/collision) (Exiting).
+ public static PRECISION BounceOut(PRECISION x) => BounceOut_Raw(x);
+ /// Bounce easing (simulated gravity/collision) (Entering and Exiting).
+ public static PRECISION BounceInOut(PRECISION x) => BounceInOut_Raw(x);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION BounceIn_Raw(PRECISION x) => 1.0f - BounceOut_Impl(1.0f - x);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION BounceOut_Raw(PRECISION x) => BounceOut_Impl(x);
+ [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static PRECISION BounceInOut_Raw(PRECISION x) => x < 0.5f ? (1.0f - BounceOut_Impl(1.0f - (2.0f * x))) * 0.5f : (1.0f + BounceOut_Impl((2.0f * x) - 1.0f)) * 0.5f;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static PRECISION BounceOut_Impl(PRECISION x)
@@ -208,14 +231,5 @@ private static PRECISION BounceOut_Impl(PRECISION x)
x < 2.5f * d1_inv ? (n1 * (x - (2.25f * d1_inv)) * (x - (2.25f * d1_inv))) + 0.9375f :
(n1 * (x - (2.625f * d1_inv)) * (x - (2.625f * d1_inv))) + 0.984375f;
}
-
- /// Bounce easing (simulated gravity/collision) (Entering).
- public static PRECISION BounceIn(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : 1.0f - BounceOut_Impl(1.0f - x)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
- /// Bounce easing (simulated gravity/collision) (Exiting).
- public static PRECISION BounceOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : BounceOut_Impl(x)); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
-
- /// Bounce easing (simulated gravity/collision) (Entering and Exiting).
- public static PRECISION BounceInOut(PRECISION x) => x <= 0.0f ? 0.0f : (x >= 1.0f ? 1.0f : x < 0.5f ? (1.0f - BounceOut_Impl(1.0f - (2.0f * x))) * 0.5f : (1.0f + BounceOut_Impl((2.0f * x) - 1.0f)) * 0.5f); // (x == 0 ? 0 : (x == 1 ? 1 : ...))
}
}
diff --git a/ExpectedValueGenerator.cs b/ExpectedValueGenerator.cs
index 5888ea8..34d41a3 100644
--- a/ExpectedValueGenerator.cs
+++ b/ExpectedValueGenerator.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using SatorImaging.UnityFundamentals;
public class ExpectedValueGenerator
{
@@ -34,85 +35,49 @@ public static void Main()
Console.WriteLine(" };");
}
- private const double c1 = 1.70158;
- private const double c2 = c1 * 1.525;
- private const double ln_2 = 0.6931471805599453;
- private static readonly double e_c4 = 2.0 * Math.PI / 3.0;
- private static readonly double e_c5 = 2.0 * Math.PI / 4.5;
-
- // Use approximate functions as defined in EasingDouble.cs to see actual behavior before guards
- private static double Sin5(double t)
- {
- const double inv6 = 1.0 / 6.0;
- const double invC = 0.007860176264317486;
- return t - (t * t * t * inv6) + (t * t * t * t * t * invC);
- }
-
- private static double FastSqrt(double x)
- {
- double xHalf = x * 0.5;
- long i = BitConverter.DoubleToInt64Bits(x);
- i = 0x5fe6eb50c7b537a9L - (i >> 1);
- double y = BitConverter.Int64BitsToDouble(i);
- y *= 1.501750997142437871 - (xHalf * y * y);
- return x * y;
- }
-
- private static double BounceOut_Impl(double x)
- {
- const double n1 = 7.5625;
- const double d1_inv = 1.0 / 2.75;
- if (x < 1.0 * d1_inv) return n1 * x * x;
- else if (x < 2.0 * d1_inv) return n1 * (x - (1.5 * d1_inv)) * (x - (1.5 * d1_inv)) + 0.75;
- else if (x < 2.5 * d1_inv) return n1 * (x - (2.25 * d1_inv)) * (x - (2.25 * d1_inv)) + 0.9375;
- else return n1 * (x - (2.625 * d1_inv)) * (x - (2.625 * d1_inv)) + 0.984375;
- }
-
private static double Calculate(string name, double x)
{
switch (name)
{
- case "QuadIn": return x * x;
- case "QuadOut": return 1.0 - ((1.0 - x) * (1.0 - x));
- case "QuadInOut": return x < 0.5 ? 2.0 * x * x : 1.0 - (Math.Pow(-2.0 * x + 2.0, 2) * 0.5);
+ case "QuadIn": return EasingDouble.QuadIn_Raw(x);
+ case "QuadOut": return EasingDouble.QuadOut_Raw(x);
+ case "QuadInOut": return EasingDouble.QuadInOut_Raw(x);
- case "CubicIn": return x * x * x;
- case "CubicOut": return 1.0 - ((1.0 - x) * (1.0 - x) * (1.0 - x));
- case "CubicInOut": return x < 0.5 ? 4.0 * x * x * x : 1.0 - (Math.Pow(-2.0 * x + 2.0, 3) * 0.5);
+ case "CubicIn": return EasingDouble.CubicIn_Raw(x);
+ case "CubicOut": return EasingDouble.CubicOut_Raw(x);
+ case "CubicInOut": return EasingDouble.CubicInOut_Raw(x);
- case "QuartIn": return x * x * x * x;
- case "QuartOut": return 1.0 - ((1.0 - x) * (1.0 - x) * (1.0 - x) * (1.0 - x));
- case "QuartInOut": return x < 0.5 ? 8.0 * x * x * x * x : 1.0 - (Math.Pow(-2.0 * x + 2.0, 4) * 0.5);
+ case "QuartIn": return EasingDouble.QuartIn_Raw(x);
+ case "QuartOut": return EasingDouble.QuartOut_Raw(x);
+ case "QuartInOut": return EasingDouble.QuartInOut_Raw(x);
- case "QuintIn": return x * x * x * x * x;
- case "QuintOut": return 1.0 - ((1.0 - x) * (1.0 - x) * (1.0 - x) * (1.0 - x) * (1.0 - x));
- case "QuintInOut": return x < 0.5 ? 16.0 * x * x * x * x * x : 1.0 - (Math.Pow(-2.0 * x + 2.0, 5) * 0.5);
+ case "QuintIn": return EasingDouble.QuintIn_Raw(x);
+ case "QuintOut": return EasingDouble.QuintOut_Raw(x);
+ case "QuintInOut": return EasingDouble.QuintInOut_Raw(x);
- case "SineIn": return 1.0 - Sin5((1.0 - x) * Math.PI * 0.5);
- case "SineOut": return Sin5(x * Math.PI * 0.5);
- case "SineInOut": return (1.0 - Sin5((0.5 - x) * Math.PI)) * 0.5;
+ case "SineIn": return EasingDouble.SineIn_Raw(x);
+ case "SineOut": return EasingDouble.SineOut_Raw(x);
+ case "SineInOut": return EasingDouble.SineInOut_Raw(x);
- case "ExpoIn": return Math.Exp(((10.0 * x) - 10.0) * ln_2);
- case "ExpoOut": return 1.0 - Math.Exp((-10.0 * x) * ln_2);
- case "ExpoInOut": return x < 0.5 ? Math.Exp(((20.0 * x) - 10.0) * ln_2) * 0.5 : (2.0 - Math.Exp((10.0 - (20.0 * x)) * ln_2)) * 0.5;
+ case "ExpoIn": return EasingDouble.ExpoIn_Raw(x);
+ case "ExpoOut": return EasingDouble.ExpoOut_Raw(x);
+ case "ExpoInOut": return EasingDouble.ExpoInOut_Raw(x);
- case "CircIn": return 1.0 - FastSqrt(1.0 - (x * x));
- case "CircOut": return FastSqrt(1.0 - ((x - 1.0) * (x - 1.0)));
- case "CircInOut": return x < 0.5 ? (1.0 - FastSqrt(1.0 - ((2.0 * x) * (2.0 * x)))) * 0.5 : (FastSqrt(1.0 - ((2.0 - (2.0 * x)) * (2.0 - (2.0 * x)))) + 1.0) * 0.5;
+ case "CircIn": return EasingDouble.CircIn_Raw(x);
+ case "CircOut": return EasingDouble.CircOut_Raw(x);
+ case "CircInOut": return EasingDouble.CircInOut_Raw(x);
- case "BackIn": return ((c1 + 1.0) * x * x * x) - (c1 * x * x);
- case "BackOut": return 1.0 + ((c1 + 1.0) * Math.Pow(x - 1.0, 3)) + (c1 * Math.Pow(x - 1.0, 2));
- case "BackInOut": return x < 0.5 ? ((2.0 * x) * (2.0 * x) * (((c2 + 1.0) * (2.0 * x)) - c2)) * 0.5 : (((2.0 * x - 2.0) * (2.0 * x - 2.0) * (((c2 + 1.0) * (2.0 * x - 2.0)) + c2)) + 2.0) * 0.5;
+ case "BackIn": return EasingDouble.BackIn_Raw(x);
+ case "BackOut": return EasingDouble.BackOut_Raw(x);
+ case "BackInOut": return EasingDouble.BackInOut_Raw(x);
- case "ElasticIn": return -Math.Exp(((10.0 * x) - 10.0) * ln_2) * Math.Sin(((10.0 * x) - 10.75) * e_c4);
- case "ElasticOut": return (Math.Exp((-10.0 * x) * ln_2) * Math.Sin(((10.0 * x) - 0.75) * e_c4)) + 1.0;
- case "ElasticInOut": return x < 0.5 ? -Math.Exp(((20.0 * x) - 10.0) * ln_2) * Math.Sin(((20.0 * x) - 11.125) * e_c5) * 0.5 : (Math.Exp((10.0 - (20.0 * x)) * ln_2) * Math.Sin(((20.0 * x) - 11.125) * e_c5) * 0.5) + 1.0;
+ case "ElasticIn": return EasingDouble.ElasticIn_Raw(x);
+ case "ElasticOut": return EasingDouble.ElasticOut_Raw(x);
+ case "ElasticInOut": return EasingDouble.ElasticInOut_Raw(x);
- case "BounceIn": return 1.0 - BounceOut_Impl(1.0 - x);
- case "BounceOut": return BounceOut_Impl(x);
- case "BounceInOut":
- double t = 2.0 * x;
- return x < 0.5 ? (1.0 - BounceOut_Impl(1.0 - t)) * 0.5 : (1.0 + BounceOut_Impl(t - 1.0)) * 0.5;
+ case "BounceIn": return EasingDouble.BounceIn_Raw(x);
+ case "BounceOut": return EasingDouble.BounceOut_Raw(x);
+ case "BounceInOut": return EasingDouble.BounceInOut_Raw(x);
default: throw new Exception("Unknown");
}