Example #1
0
        /// <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);
        }
Example #2
0
 /// <summary>
 /// Clamps the specified value within a range.
 /// </summary>
 /// <param name="value1">The value to clamp.</param>
 /// <param name="min">The min value.</param>
 /// <param name="max">The max value.</param>
 /// <param name="result">The clamped value as an output parameter.</param>
 public static void Clamp(ref Vector2f value1, ref Vector2f min, ref Vector2f max, out Vector2f result)
 {
     result.X = Maths.Clamp(value1.X, min.X, max.X);
     result.Y = Maths.Clamp(value1.Y, min.Y, max.Y);
 }
Example #3
0
 /// <summary>
 /// Clamps the specified value within a range.
 /// </summary>
 /// <param name="value1">The value to clamp.</param>
 /// <param name="min">The min value.</param>
 /// <param name="max">The max value.</param>
 /// <returns>The clamped value.</returns>
 public static Vector2f Clamp(Vector2f value1, Vector2f min, Vector2f max)
 {
     return(new Vector2f(
                Maths.Clamp(value1.X, min.X, max.X),
                Maths.Clamp(value1.Y, min.Y, max.Y)));
 }