/// <summary> /// Performs a linear interpolation between two colors. /// </summary> /// <param name="start">Start color.</param> /// <param name="end">End color.</param> /// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end"/>.</param> /// <param name="result">When the method completes, contains the linear interpolation of the two colors.</param> /// <remarks> /// Passing <paramref name="amount"/> a value of 0 will cause <paramref name="start"/> to be returned; a value of 1 will cause <paramref name="end"/> to be returned. /// </remarks> public static void Lerp(ref Color4 start, ref Color4 end, float amount, out Color4 result) { result.Red = MathUtil.Lerp(start.Red, end.Red, amount); result.Green = MathUtil.Lerp(start.Green, end.Green, amount); result.Blue = MathUtil.Lerp(start.Blue, end.Blue, amount); result.Alpha = MathUtil.Lerp(start.Alpha, end.Alpha, amount); }
/// <summary> /// Performs a linear interpolation between two colors. /// </summary> /// <param name="start">Start color.</param> /// <param name="end">End color.</param> /// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end"/>.</param> /// <param name="result">When the method completes, contains the linear interpolation of the two colors.</param> /// <remarks> /// Passing <paramref name="amount"/> a value of 0 will cause <paramref name="start"/> to be returned; a value of 1 will cause <paramref name="end"/> to be returned. /// </remarks> public static void Lerp(ref Color start, ref Color end, float amount, out Color result) { result.R = MathUtil.Lerp(start.R, end.R, amount); result.G = MathUtil.Lerp(start.G, end.G, amount); result.B = MathUtil.Lerp(start.B, end.B, amount); result.A = MathUtil.Lerp(start.A, end.A, amount); }
/// <summary> /// Performs a linear interpolation between two matrices. /// </summary> /// <param name="start">Start matrix.</param> /// <param name="end">End matrix.</param> /// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end"/>.</param> /// <param name="result">When the method completes, contains the linear interpolation of the two matrices.</param> /// <remarks> /// Passing <paramref name="amount"/> a value of 0 will cause <paramref name="start"/> to be returned; a value of 1 will cause <paramref name="end"/> to be returned. /// </remarks> public static void Lerp(ref Matrix3x2 start, ref Matrix3x2 end, float amount, out Matrix3x2 result) { result.M11 = MathUtil.Lerp(start.M11, end.M11, amount); result.M12 = MathUtil.Lerp(start.M12, end.M12, amount); result.M21 = MathUtil.Lerp(start.M21, end.M21, amount); result.M22 = MathUtil.Lerp(start.M22, end.M22, amount); result.M31 = MathUtil.Lerp(start.M31, end.M31, amount); result.M32 = MathUtil.Lerp(start.M32, end.M32, amount); }
/// <summary> /// Performs a linear interpolation between two matrices. /// </summary> /// <param name="start">Start Matrix5x4.</param> /// <param name="end">End Matrix5x4.</param> /// <param name="amount">Value between 0 and 1 indicating the weight of <paramref name="end"/>.</param> /// <param name="result">When the method completes, contains the linear interpolation of the two matrices.</param> /// <remarks> /// Passing <paramref name="amount"/> a value of 0 will cause <paramref name="start"/> to be returned; a value of 1 will cause <paramref name="end"/> to be returned. /// </remarks> public static void Lerp(ref Matrix5x4 start, ref Matrix5x4 end, float amount, out Matrix5x4 result) { result.M11 = MathUtil.Lerp(start.M11, end.M11, amount); result.M12 = MathUtil.Lerp(start.M12, end.M12, amount); result.M13 = MathUtil.Lerp(start.M13, end.M13, amount); result.M14 = MathUtil.Lerp(start.M14, end.M14, amount); result.M21 = MathUtil.Lerp(start.M21, end.M21, amount); result.M22 = MathUtil.Lerp(start.M22, end.M22, amount); result.M23 = MathUtil.Lerp(start.M23, end.M23, amount); result.M24 = MathUtil.Lerp(start.M24, end.M24, amount); result.M31 = MathUtil.Lerp(start.M31, end.M31, amount); result.M32 = MathUtil.Lerp(start.M32, end.M32, amount); result.M33 = MathUtil.Lerp(start.M33, end.M33, amount); result.M34 = MathUtil.Lerp(start.M34, end.M34, amount); result.M41 = MathUtil.Lerp(start.M41, end.M41, amount); result.M42 = MathUtil.Lerp(start.M42, end.M42, amount); result.M43 = MathUtil.Lerp(start.M43, end.M43, amount); result.M44 = MathUtil.Lerp(start.M44, end.M44, amount); result.M51 = MathUtil.Lerp(start.M51, end.M51, amount); result.M52 = MathUtil.Lerp(start.M52, end.M52, amount); result.M53 = MathUtil.Lerp(start.M53, end.M53, amount); result.M54 = MathUtil.Lerp(start.M54, end.M54, amount); }
/// <summary> /// Gets random <c>double</c> number within range. /// </summary> /// <param name="random">Current <see cref="System.Random"/>.</param> /// <param name="min">Minimum.</param> /// <param name="max">Maximum.</param> /// <returns>Random <c>double</c> number.</returns> public static double NextDouble(this Random random, double min, double max) { return(MathUtil.Lerp(min, max, random.NextDouble())); }
/// <summary> /// Gets random <c>float</c> number within range. /// </summary> /// <param name="random">Current <see cref="System.Random"/>.</param> /// <param name="min">Minimum.</param> /// <param name="max">Maximum.</param> /// <returns>Random <c>float</c> number.</returns> public static float NextFloat(this Random random, float min, float max) { return(MathUtil.Lerp(min, max, (float)random.NextDouble())); }