From 8d4f82e96488b11acd9a56dd829c68fdc4b388e2 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Fri, 29 Apr 2022 23:24:30 +0100 Subject: [PATCH] Remove Lerp extension methods These extension methods lead to confusion with the parameter order, and so the advice now is to simply use MathUtility.Lerp directly --- X10D.Tests/src/Core/DoubleTests.cs | 18 ------ X10D/src/Math/DoubleExtensions.cs | 48 --------------- X10D/src/Math/Int16Extensions.cs | 48 --------------- X10D/src/Math/Int32Extensions.cs | 96 ------------------------------ X10D/src/Math/Int64Extensions.cs | 96 ------------------------------ X10D/src/Math/SingleExtensions.cs | 48 --------------- 6 files changed, 354 deletions(-) diff --git a/X10D.Tests/src/Core/DoubleTests.cs b/X10D.Tests/src/Core/DoubleTests.cs index ace6244..dbb297e 100644 --- a/X10D.Tests/src/Core/DoubleTests.cs +++ b/X10D.Tests/src/Core/DoubleTests.cs @@ -30,24 +30,6 @@ public class DoubleTests Assert.AreEqual(Complex.Infinity, double.PositiveInfinity.ComplexSqrt()); } - /// - /// Test for - /// - [TestMethod] - public void LerpTo() - { - const double a = 0.0; - const double b = 1.0; - const double t = 0.5; - const double expected = 0.5; - - double actual = a.LerpFrom(b, t); - - Trace.WriteLine($"expected = {expected}"); - Trace.WriteLine($"{a}.LerpTo({b}, {t}) = {actual}"); - Assert.AreEqual(expected, actual, $"{a}.LerpTo({b}, {t})"); - } - /// /// Tests for . /// diff --git a/X10D/src/Math/DoubleExtensions.cs b/X10D/src/Math/DoubleExtensions.cs index 23bc74d..0fec4a3 100644 --- a/X10D/src/Math/DoubleExtensions.cs +++ b/X10D/src/Math/DoubleExtensions.cs @@ -190,54 +190,6 @@ public static class DoubleExtensions return !value.IsEven(); } - /// - /// Linearly interpolates to the current value from a specified source using a specified alpha. - /// - /// The interpolation target. - /// The interpolation source. - /// The interpolation alpha. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static double LerpFrom(this double target, double value, double alpha) - { - return MathUtility.Lerp(value, target, alpha); - } - - /// - /// Linearly interpolates from the current value to a specified target using a specified alpha. - /// - /// The interpolation source. - /// The interpolation target. - /// The interpolation alpha. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static double LerpTo(this double value, double target, double alpha) - { - return MathUtility.Lerp(value, target, alpha); - } - - /// - /// Linearly interpolates to a specified target from a specified source, using the current value as the alpha value. - /// - /// The interpolation alpha. - /// The interpolation source. - /// The interpolation target. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static double LerpWith(this double alpha, double value, double target) - { - return MathUtility.Lerp(value, target, alpha); - } - /// /// Converts the current angle in radians to its equivalent represented in degrees. /// diff --git a/X10D/src/Math/Int16Extensions.cs b/X10D/src/Math/Int16Extensions.cs index abe7e67..702ba6c 100644 --- a/X10D/src/Math/Int16Extensions.cs +++ b/X10D/src/Math/Int16Extensions.cs @@ -98,54 +98,6 @@ public static class Int16Extensions return ((long)value).IsPrime(); } - /// - /// Linearly interpolates to the current value from a specified source using a specified alpha. - /// - /// The interpolation target. - /// The interpolation source. - /// The interpolation alpha. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static double LerpFrom(this short target, double value, double alpha) - { - return MathUtility.Lerp(value, target, alpha); - } - - /// - /// Linearly interpolates to the current value from a specified source using a specified alpha. - /// - /// The interpolation target. - /// The interpolation source. - /// The interpolation alpha. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static float LerpFrom(this short target, float value, float alpha) - { - return MathUtility.Lerp(value, target, alpha); - } - - /// - /// Linearly interpolates from the current value to a specified target using a specified alpha. - /// - /// The interpolation source. - /// The interpolation target. - /// The interpolation alpha. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static double LerpTo(this short value, double target, double alpha) - { - return MathUtility.Lerp(value, target, alpha); - } - /// /// Performs a modulo operation which supports a negative dividend. /// diff --git a/X10D/src/Math/Int32Extensions.cs b/X10D/src/Math/Int32Extensions.cs index 2a8c8fa..a3099cd 100644 --- a/X10D/src/Math/Int32Extensions.cs +++ b/X10D/src/Math/Int32Extensions.cs @@ -98,102 +98,6 @@ public static class Int32Extensions return ((long)value).IsPrime(); } - /// - /// Linearly interpolates to the current value from a specified source using a specified alpha. - /// - /// The interpolation target. - /// The interpolation source. - /// The interpolation alpha. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static double LerpFrom(this int target, double value, double alpha) - { - return MathUtility.Lerp(value, target, alpha); - } - - /// - /// Linearly interpolates to the current value from a specified source using a specified alpha. - /// - /// The interpolation target. - /// The interpolation source. - /// The interpolation alpha. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static float LerpFrom(this int target, float value, float alpha) - { - return MathUtility.Lerp(value, target, alpha); - } - - /// - /// Linearly interpolates from the current value to a specified target using a specified alpha. - /// - /// The interpolation source. - /// The interpolation target. - /// The interpolation alpha. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static double LerpTo(this int value, double target, double alpha) - { - return MathUtility.Lerp(value, target, alpha); - } - - /// - /// Linearly interpolates from the current value to a specified target using a specified alpha. - /// - /// The interpolation source. - /// The interpolation target. - /// The interpolation alpha. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static float LerpTo(this int value, float target, float alpha) - { - return MathUtility.Lerp(value, target, alpha); - } - - /// - /// Linearly interpolates to a specified target from a specified source, using the current value as the alpha value. - /// - /// The interpolation alpha. - /// The interpolation source. - /// The interpolation target. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static double LerpWith(this int alpha, double value, double target) - { - return MathUtility.Lerp(value, target, alpha); - } - - /// - /// Linearly interpolates to a specified target from a specified source, using the current value as the alpha value. - /// - /// The interpolation alpha. - /// The interpolation source. - /// The interpolation target. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static float LerpWith(this int alpha, float value, float target) - { - return MathUtility.Lerp(value, target, alpha); - } - /// /// Performs a modulo operation which supports a negative dividend. /// diff --git a/X10D/src/Math/Int64Extensions.cs b/X10D/src/Math/Int64Extensions.cs index 8aa920f..56ab1dd 100644 --- a/X10D/src/Math/Int64Extensions.cs +++ b/X10D/src/Math/Int64Extensions.cs @@ -123,102 +123,6 @@ public static class Int64Extensions return true; } - /// - /// Linearly interpolates to the current value from a specified source using a specified alpha. - /// - /// The interpolation target. - /// The interpolation source. - /// The interpolation alpha. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static double LerpFrom(this long target, double value, double alpha) - { - return MathUtility.Lerp(value, target, alpha); - } - - /// - /// Linearly interpolates to the current value from a specified source using a specified alpha. - /// - /// The interpolation target. - /// The interpolation source. - /// The interpolation alpha. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static float LerpFrom(this long target, float value, float alpha) - { - return MathUtility.Lerp(value, target, alpha); - } - - /// - /// Linearly interpolates from the current value to a specified target using a specified alpha. - /// - /// The interpolation source. - /// The interpolation target. - /// The interpolation alpha. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static double LerpTo(this long value, double target, double alpha) - { - return MathUtility.Lerp(value, target, alpha); - } - - /// - /// Linearly interpolates from the current value to a specified target using a specified alpha. - /// - /// The interpolation source. - /// The interpolation target. - /// The interpolation alpha. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static float LerpTo(this long value, float target, float alpha) - { - return MathUtility.Lerp(value, target, alpha); - } - - /// - /// Linearly interpolates to a specified target from a specified source, using the current value as the alpha value. - /// - /// The interpolation alpha. - /// The interpolation source. - /// The interpolation target. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static double LerpWith(this long alpha, double value, double target) - { - return MathUtility.Lerp(value, target, alpha); - } - - /// - /// Linearly interpolates to a specified target from a specified source, using the current value as the alpha value. - /// - /// The interpolation alpha. - /// The interpolation source. - /// The interpolation target. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static float LerpWith(this long alpha, float value, float target) - { - return MathUtility.Lerp(value, target, alpha); - } - /// /// Performs a modulo operation which supports a negative dividend. /// diff --git a/X10D/src/Math/SingleExtensions.cs b/X10D/src/Math/SingleExtensions.cs index 7c7e22e..f7316b0 100644 --- a/X10D/src/Math/SingleExtensions.cs +++ b/X10D/src/Math/SingleExtensions.cs @@ -190,54 +190,6 @@ public static class SingleExtensions return !value.IsEven(); } - /// - /// Linearly interpolates to the current value from a specified source using a specified alpha. - /// - /// The interpolation target. - /// The interpolation source. - /// The interpolation alpha. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static float LerpFrom(this float target, float value, float alpha) - { - return MathUtility.Lerp(value, target, alpha); - } - - /// - /// Linearly interpolates from the current value to a specified target using a specified alpha. - /// - /// The interpolation source. - /// The interpolation target. - /// The interpolation alpha. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static float LerpTo(this float value, float target, float alpha) - { - return MathUtility.Lerp(value, target, alpha); - } - - /// - /// Linearly interpolates to a specified target from a specified source, using the current value as the alpha value. - /// - /// The interpolation alpha. - /// The interpolation source. - /// The interpolation target. - /// - /// The interpolation result as determined by (1 - alpha) * value + alpha * target. - /// - [Pure] - [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] - public static float LerpWith(this float alpha, float value, float target) - { - return MathUtility.Lerp(value, target, alpha); - } - /// /// Converts the current angle in radians to its equivalent represented in degrees. ///