From 1ee7e59f91c5e2b7ef57d5edefa21f845fd8dca8 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 16 Mar 2021 14:46:49 +0000 Subject: [PATCH] (#38) Add short/int/long.Lerp --- X10D/src/Int16Extensions/Int16Extensions.cs | 90 +++++++++++++++++++++ X10D/src/Int32Extensions/Int32Extensions.cs | 90 +++++++++++++++++++++ X10D/src/Int64Extensions/Int64Extensions.cs | 90 +++++++++++++++++++++ 3 files changed, 270 insertions(+) diff --git a/X10D/src/Int16Extensions/Int16Extensions.cs b/X10D/src/Int16Extensions/Int16Extensions.cs index fce9df0..0f1a8d3 100644 --- a/X10D/src/Int16Extensions/Int16Extensions.cs +++ b/X10D/src/Int16Extensions/Int16Extensions.cs @@ -82,6 +82,96 @@ namespace X10D.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 - ) * + + /// * . + /// + public static double LerpFrom(this short target, double value, double alpha) + { + return DoubleExtensions.DoubleExtensions.LerpInternal(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 - ) * + + /// * . + /// + public static double LerpTo(this short value, double target, double alpha) + { + return DoubleExtensions.DoubleExtensions.LerpInternal(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 - ) * + + /// * . + /// + public static double LerpWith(this short alpha, double value, double target) + { + return DoubleExtensions.DoubleExtensions.LerpInternal(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 - ) * + + /// * . + /// + public static float LerpFrom(this short target, float value, float alpha) + { + return SingleExtensions.SingleExtensions.LerpInternal(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 - ) * + + /// * . + /// + public static float LerpTo(this short value, float target, float alpha) + { + return SingleExtensions.SingleExtensions.LerpInternal(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 - ) * + + /// * . + /// + public static float LerpWith(this short alpha, float value, float target) + { + return SingleExtensions.SingleExtensions.LerpInternal(value, target, alpha); + } + /// /// Converts the value of the current 16-bit signed integer to an equivalent value. /// diff --git a/X10D/src/Int32Extensions/Int32Extensions.cs b/X10D/src/Int32Extensions/Int32Extensions.cs index ea11349..d46f825 100644 --- a/X10D/src/Int32Extensions/Int32Extensions.cs +++ b/X10D/src/Int32Extensions/Int32Extensions.cs @@ -82,6 +82,96 @@ namespace X10D.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 - ) * + + /// * . + /// + public static double LerpFrom(this int target, double value, double alpha) + { + return DoubleExtensions.DoubleExtensions.LerpInternal(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 - ) * + + /// * . + /// + public static double LerpTo(this int value, double target, double alpha) + { + return DoubleExtensions.DoubleExtensions.LerpInternal(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 - ) * + + /// * . + /// + public static double LerpWith(this int alpha, double value, double target) + { + return DoubleExtensions.DoubleExtensions.LerpInternal(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 - ) * + + /// * . + /// + public static float LerpFrom(this int target, float value, float alpha) + { + return SingleExtensions.SingleExtensions.LerpInternal(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 - ) * + + /// * . + /// + public static float LerpTo(this int value, float target, float alpha) + { + return SingleExtensions.SingleExtensions.LerpInternal(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 - ) * + + /// * . + /// + public static float LerpWith(this int alpha, float value, float target) + { + return SingleExtensions.SingleExtensions.LerpInternal(value, target, alpha); + } + /// /// Converts the value of the current 32-bit signed integer to an equivalent value. /// diff --git a/X10D/src/Int64Extensions/Int64Extensions.cs b/X10D/src/Int64Extensions/Int64Extensions.cs index 968aab0..6e63a13 100644 --- a/X10D/src/Int64Extensions/Int64Extensions.cs +++ b/X10D/src/Int64Extensions/Int64Extensions.cs @@ -105,6 +105,96 @@ namespace X10D.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 - ) * + + /// * . + /// + public static double LerpFrom(this long target, double value, double alpha) + { + return DoubleExtensions.DoubleExtensions.LerpInternal(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 - ) * + + /// * . + /// + public static double LerpTo(this long value, double target, double alpha) + { + return DoubleExtensions.DoubleExtensions.LerpInternal(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 - ) * + + /// * . + /// + public static double LerpWith(this long alpha, double value, double target) + { + return DoubleExtensions.DoubleExtensions.LerpInternal(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 - ) * + + /// * . + /// + public static float LerpFrom(this long target, float value, float alpha) + { + return SingleExtensions.SingleExtensions.LerpInternal(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 - ) * + + /// * . + /// + public static float LerpTo(this long value, float target, float alpha) + { + return SingleExtensions.SingleExtensions.LerpInternal(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 - ) * + + /// * . + /// + public static float LerpWith(this long alpha, float value, float target) + { + return SingleExtensions.SingleExtensions.LerpInternal(value, target, alpha); + } + /// /// Converts the value of the current 64-bit signed integer to an equivalent Boolean value. ///