示例#1
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 Vector2D Clamp(Vector2D value1, Vector2D min, Vector2D max)
 {
     return(new Vector2D(
                MathHelperD.Clamp(value1.X, min.X, max.X),
                MathHelperD.Clamp(value1.Y, min.Y, max.Y)
                ));
 }
示例#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 Vector2D value1,
     ref Vector2D min,
     ref Vector2D max,
     out Vector2D result
     )
 {
     result.X = MathHelperD.Clamp(value1.X, min.X, max.X);
     result.Y = MathHelperD.Clamp(value1.Y, min.Y, max.Y);
 }
示例#3
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 double SmoothStep(double value1, double value2, double amount)
        {
            /* It is expected that 0 < amount < 1.
             * If amount < 0, return value1.
             * If amount > 1, return value2.
             */
            double result = MathHelperD.Clamp(amount, 0f, 1f);

            result = MathHelperD.Hermite(value1, 0f, value2, 0f, result);

            return(result);
        }