mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-23 00:18:47 +00:00
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
This commit is contained in:
parent
155a604812
commit
8d4f82e964
@ -30,24 +30,6 @@ public class DoubleTests
|
|||||||
Assert.AreEqual(Complex.Infinity, double.PositiveInfinity.ComplexSqrt());
|
Assert.AreEqual(Complex.Infinity, double.PositiveInfinity.ComplexSqrt());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Test for <see cref="DoubleExtensions.LerpTo" />
|
|
||||||
/// </summary>
|
|
||||||
[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})");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests for <see cref="DoubleExtensions.DegreesToRadians" />.
|
/// Tests for <see cref="DoubleExtensions.DegreesToRadians" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -190,54 +190,6 @@ public static class DoubleExtensions
|
|||||||
return !value.IsEven();
|
return !value.IsEven();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates to the current value from a specified source using a specified alpha.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static double LerpFrom(this double target, double value, double alpha)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates from the current value to a specified target using a specified alpha.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static double LerpTo(this double value, double target, double alpha)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates to a specified target from a specified source, using the current value as the alpha value.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static double LerpWith(this double alpha, double value, double target)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts the current angle in radians to its equivalent represented in degrees.
|
/// Converts the current angle in radians to its equivalent represented in degrees.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -98,54 +98,6 @@ public static class Int16Extensions
|
|||||||
return ((long)value).IsPrime();
|
return ((long)value).IsPrime();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates to the current value from a specified source using a specified alpha.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static double LerpFrom(this short target, double value, double alpha)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates to the current value from a specified source using a specified alpha.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static float LerpFrom(this short target, float value, float alpha)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates from the current value to a specified target using a specified alpha.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static double LerpTo(this short value, double target, double alpha)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Performs a modulo operation which supports a negative dividend.
|
/// Performs a modulo operation which supports a negative dividend.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -98,102 +98,6 @@ public static class Int32Extensions
|
|||||||
return ((long)value).IsPrime();
|
return ((long)value).IsPrime();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates to the current value from a specified source using a specified alpha.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static double LerpFrom(this int target, double value, double alpha)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates to the current value from a specified source using a specified alpha.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static float LerpFrom(this int target, float value, float alpha)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates from the current value to a specified target using a specified alpha.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static double LerpTo(this int value, double target, double alpha)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates from the current value to a specified target using a specified alpha.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static float LerpTo(this int value, float target, float alpha)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates to a specified target from a specified source, using the current value as the alpha value.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static double LerpWith(this int alpha, double value, double target)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates to a specified target from a specified source, using the current value as the alpha value.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static float LerpWith(this int alpha, float value, float target)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Performs a modulo operation which supports a negative dividend.
|
/// Performs a modulo operation which supports a negative dividend.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -123,102 +123,6 @@ public static class Int64Extensions
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates to the current value from a specified source using a specified alpha.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static double LerpFrom(this long target, double value, double alpha)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates to the current value from a specified source using a specified alpha.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static float LerpFrom(this long target, float value, float alpha)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates from the current value to a specified target using a specified alpha.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static double LerpTo(this long value, double target, double alpha)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates from the current value to a specified target using a specified alpha.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static float LerpTo(this long value, float target, float alpha)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates to a specified target from a specified source, using the current value as the alpha value.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static double LerpWith(this long alpha, double value, double target)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates to a specified target from a specified source, using the current value as the alpha value.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static float LerpWith(this long alpha, float value, float target)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Performs a modulo operation which supports a negative dividend.
|
/// Performs a modulo operation which supports a negative dividend.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -190,54 +190,6 @@ public static class SingleExtensions
|
|||||||
return !value.IsEven();
|
return !value.IsEven();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates to the current value from a specified source using a specified alpha.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static float LerpFrom(this float target, float value, float alpha)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates from the current value to a specified target using a specified alpha.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static float LerpTo(this float value, float target, float alpha)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Linearly interpolates to a specified target from a specified source, using the current value as the alpha value.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="alpha">The interpolation alpha.</param>
|
|
||||||
/// <param name="value">The interpolation source.</param>
|
|
||||||
/// <param name="target">The interpolation target.</param>
|
|
||||||
/// <returns>
|
|
||||||
/// The interpolation result as determined by <c>(1 - alpha) * value + alpha * target</c>.
|
|
||||||
/// </returns>
|
|
||||||
[Pure]
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
|
||||||
public static float LerpWith(this float alpha, float value, float target)
|
|
||||||
{
|
|
||||||
return MathUtility.Lerp(value, target, alpha);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Converts the current angle in radians to its equivalent represented in degrees.
|
/// Converts the current angle in radians to its equivalent represented in degrees.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user