1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-23 00:38:47 +00:00

(#38) Add short/int/long.Lerp

This commit is contained in:
Oliver Booth 2021-03-16 14:46:49 +00:00
parent c3cb8ba261
commit 1ee7e59f91
3 changed files with 270 additions and 0 deletions

View File

@ -82,6 +82,96 @@ namespace X10D.Int16Extensions
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 - <paramref name="alpha" />) * <paramref name="value" /> +
/// <paramref name="alpha" /> * <paramref name="target" /></c>.
/// </returns>
public static double LerpFrom(this short target, double value, double alpha)
{
return DoubleExtensions.DoubleExtensions.LerpInternal(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 - <paramref name="alpha" />) * <paramref name="value" /> +
/// <paramref name="alpha" /> * <paramref name="target" /></c>.
/// </returns>
public static double LerpTo(this short value, double target, double alpha)
{
return DoubleExtensions.DoubleExtensions.LerpInternal(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 - <paramref name="alpha" />) * <paramref name="value" /> +
/// <paramref name="alpha" /> * <paramref name="target" /></c>.
/// </returns>
public static double LerpWith(this short alpha, double value, double target)
{
return DoubleExtensions.DoubleExtensions.LerpInternal(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 - <paramref name="alpha" />) * <paramref name="value" /> +
/// <paramref name="alpha" /> * <paramref name="target" /></c>.
/// </returns>
public static float LerpFrom(this short target, float value, float alpha)
{
return SingleExtensions.SingleExtensions.LerpInternal(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 - <paramref name="alpha" />) * <paramref name="value" /> +
/// <paramref name="alpha" /> * <paramref name="target" /></c>.
/// </returns>
public static float LerpTo(this short value, float target, float alpha)
{
return SingleExtensions.SingleExtensions.LerpInternal(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 - <paramref name="alpha" />) * <paramref name="value" /> +
/// <paramref name="alpha" /> * <paramref name="target" /></c>.
/// </returns>
public static float LerpWith(this short alpha, float value, float target)
{
return SingleExtensions.SingleExtensions.LerpInternal(value, target, alpha);
}
/// <summary>
/// Converts the value of the current 16-bit signed integer to an equivalent <see cref="bool" /> value.
/// </summary>

View File

@ -82,6 +82,96 @@ namespace X10D.Int32Extensions
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 - <paramref name="alpha" />) * <paramref name="value" /> +
/// <paramref name="alpha" /> * <paramref name="target" /></c>.
/// </returns>
public static double LerpFrom(this int target, double value, double alpha)
{
return DoubleExtensions.DoubleExtensions.LerpInternal(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 - <paramref name="alpha" />) * <paramref name="value" /> +
/// <paramref name="alpha" /> * <paramref name="target" /></c>.
/// </returns>
public static double LerpTo(this int value, double target, double alpha)
{
return DoubleExtensions.DoubleExtensions.LerpInternal(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 - <paramref name="alpha" />) * <paramref name="value" /> +
/// <paramref name="alpha" /> * <paramref name="target" /></c>.
/// </returns>
public static double LerpWith(this int alpha, double value, double target)
{
return DoubleExtensions.DoubleExtensions.LerpInternal(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 - <paramref name="alpha" />) * <paramref name="value" /> +
/// <paramref name="alpha" /> * <paramref name="target" /></c>.
/// </returns>
public static float LerpFrom(this int target, float value, float alpha)
{
return SingleExtensions.SingleExtensions.LerpInternal(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 - <paramref name="alpha" />) * <paramref name="value" /> +
/// <paramref name="alpha" /> * <paramref name="target" /></c>.
/// </returns>
public static float LerpTo(this int value, float target, float alpha)
{
return SingleExtensions.SingleExtensions.LerpInternal(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 - <paramref name="alpha" />) * <paramref name="value" /> +
/// <paramref name="alpha" /> * <paramref name="target" /></c>.
/// </returns>
public static float LerpWith(this int alpha, float value, float target)
{
return SingleExtensions.SingleExtensions.LerpInternal(value, target, alpha);
}
/// <summary>
/// Converts the value of the current 32-bit signed integer to an equivalent <see cref="bool" /> value.
/// </summary>

View File

@ -105,6 +105,96 @@ namespace X10D.Int64Extensions
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 - <paramref name="alpha" />) * <paramref name="value" /> +
/// <paramref name="alpha" /> * <paramref name="target" /></c>.
/// </returns>
public static double LerpFrom(this long target, double value, double alpha)
{
return DoubleExtensions.DoubleExtensions.LerpInternal(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 - <paramref name="alpha" />) * <paramref name="value" /> +
/// <paramref name="alpha" /> * <paramref name="target" /></c>.
/// </returns>
public static double LerpTo(this long value, double target, double alpha)
{
return DoubleExtensions.DoubleExtensions.LerpInternal(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 - <paramref name="alpha" />) * <paramref name="value" /> +
/// <paramref name="alpha" /> * <paramref name="target" /></c>.
/// </returns>
public static double LerpWith(this long alpha, double value, double target)
{
return DoubleExtensions.DoubleExtensions.LerpInternal(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 - <paramref name="alpha" />) * <paramref name="value" /> +
/// <paramref name="alpha" /> * <paramref name="target" /></c>.
/// </returns>
public static float LerpFrom(this long target, float value, float alpha)
{
return SingleExtensions.SingleExtensions.LerpInternal(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 - <paramref name="alpha" />) * <paramref name="value" /> +
/// <paramref name="alpha" /> * <paramref name="target" /></c>.
/// </returns>
public static float LerpTo(this long value, float target, float alpha)
{
return SingleExtensions.SingleExtensions.LerpInternal(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 - <paramref name="alpha" />) * <paramref name="value" /> +
/// <paramref name="alpha" /> * <paramref name="target" /></c>.
/// </returns>
public static float LerpWith(this long alpha, float value, float target)
{
return SingleExtensions.SingleExtensions.LerpInternal(value, target, alpha);
}
/// <summary>
/// Converts the value of the current 64-bit signed integer to an equivalent Boolean value.
/// </summary>