/// <summary> /// Interpolates between two values using a cubic equation. /// </summary> /// <param name="value1">Source value.</param> /// <param name="value2">Source value.</param> /// <param name="amount">Weighting value.</param> /// <returns>Interpolated value.</returns> public static float SmoothStep(float value1, float value2, float amount) { // It is expected that 0 < amount < 1 // If amount < 0, return value1 // If amount > 1, return value2 float result = Maths.Clamp(amount, 0f, 1f); result = Maths.Hermite(value1, 0f, value2, 0f, result); return(result); }
/// <summary> /// Creates a new <see cref="Vector2f"/> that contains hermite spline interpolation. /// </summary> /// <param name="value1">The first position vector.</param> /// <param name="tangent1">The first tangent vector.</param> /// <param name="value2">The second position vector.</param> /// <param name="tangent2">The second tangent vector.</param> /// <param name="amount">Weighting factor.</param> /// <param name="result">The hermite spline interpolation vector as an output parameter.</param> public static void Hermite(ref Vector2f value1, ref Vector2f tangent1, ref Vector2f value2, ref Vector2f tangent2, float amount, out Vector2f result) { result.X = Maths.Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount); result.Y = Maths.Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount); }
/// <summary> /// Creates a new <see cref="Vector2f"/> that contains hermite spline interpolation. /// </summary> /// <param name="value1">The first position vector.</param> /// <param name="tangent1">The first tangent vector.</param> /// <param name="value2">The second position vector.</param> /// <param name="tangent2">The second tangent vector.</param> /// <param name="amount">Weighting factor.</param> /// <returns>The hermite spline interpolation vector.</returns> public static Vector2f Hermite(Vector2f value1, Vector2f tangent1, Vector2f value2, Vector2f tangent2, float amount) { return(new Vector2f(Maths.Hermite(value1.X, tangent1.X, value2.X, tangent2.X, amount), Maths.Hermite(value1.Y, tangent1.Y, value2.Y, tangent2.Y, amount))); }