示例#1
0
 /// <summary>
 /// Creates a <see cref="DoubleMappedFromBooleanOutput"/> object mapping the boolean values false/true to two
 /// double values.
 /// </summary>
 /// <param name="targetOutput">The target output receiving the double values.</param>
 /// <param name="falseValue">The value that the <paramref name="targetOutput"/> shall be set to when the
 /// <see cref="IBooleanInput.Value"/> property is false.</param>
 /// <param name="trueValue">The value that the <paramref name="targetOutput"/> shall be set to when the
 /// <see cref="IBooleanInput.Value"/> property is true.</param>
 /// <returns></returns>
 public static DoubleMappedFromBooleanOutput MappedFromBoolean(
     this IDoubleOutput targetOutput,
     double falseValue,
     double trueValue)
 {
     return(new DoubleMappedFromBooleanOutput(targetOutput, falseValue, trueValue));
 }
示例#2
0
 /// <summary>
 /// Creates a <see cref="DoubleSmoothedOutput"/> object which will slowly approach the
 /// <paramref name="targetOutput"/> value to the goal <see cref="IDoubleOutput.Value"/>.
 /// </summary>
 /// <param name="targetOutput">The target output to be smoothed.</param>
 /// <param name="valueChangePerSecond">The amount by that the <paramref name="targetOutput"/> value shall change
 /// per second in order to reach the <see cref="Value"/> property which definies the goal value.</param>
 /// <param name="rampIntervalMs">The interval, in milliseconds, in which the <paramref name="targetOutput"/>
 /// value shall be computed and set. The smaller this value, the more often and more smoothly will the target
 /// value be adapted.</param>
 /// <returns>The created <see cref="DoubleSmoothedOutput"/> object.</returns>
 public static DoubleSmoothedOutput Smoothed(
     this IDoubleOutput targetOutput,
     double valueChangePerSecond,
     int rampIntervalMs)
 {
     return(new DoubleSmoothedOutput(targetOutput, valueChangePerSecond, rampIntervalMs));
 }
示例#3
0
 /// <summary>
 /// Creates a <see cref="DoubleScaledOutput"/> object which will scale values quadratic and linear using a
 /// factor and an offset.
 /// </summary>
 /// <param name="targetOutput">The target output to received the scaled values.</param>
 /// <param name="quadraticCoefficient">The factor by which the square of the value will be used.</param>
 /// <param name="factor">The factor to use.</param>
 /// <param name="offset">The offset to use.</param>
 /// <returns>The created <see cref="DoubleScaledOutput"/> object.</returns>
 /// <remarks>The <paramref name="targetOutput"/> will receive values scaled by the formula:
 /// <see cref="IDoubleOutput.Value">Value</see> * <paramref name="factor"/> + <paramref name="offset"/>.
 /// </remarks>
 public static DoubleScaledOutput Scaled(
     this IDoubleOutput targetOutput,
     double quadraticCoefficient,
     double factor,
     double offset)
 {
     return(new DoubleScaledOutput(targetOutput, quadraticCoefficient, factor, offset));
 }
 /// <summary>
 /// Creates an instance given a factor only, using 0.0 as the offset.
 /// </summary>
 /// <param name="target">The target output which shall receive the scaled values.</param>
 /// <param name="factor">The factor to scale the output.</param>
 /// <remarks>Setting the <see cref="Value"/> will set the <paramref name="target"/> value to
 /// <see cref="Value"/> * <paramref name="factor"/>.</remarks>
 public DoubleScaledOutput(IDoubleOutput target, double factor)
 {
     if (target == null)
     {
         throw new ArgumentNullException(nameof(target));
     }
     _target = target;
     _factor = factor;
 }
示例#5
0
 /// <summary>
 /// Creates an instance.
 /// </summary>
 /// <param name="targetOutput">The target output receiving the double values.</param>
 /// <param name="falseValue">The value that the <paramref name="targetOutput"/> shall be set to when the
 /// <see cref="IBooleanInput.Value"/> property is false.</param>
 /// <param name="trueValue">The value that the <paramref name="targetOutput"/> shall be set to when the
 /// <see cref="IBooleanInput.Value"/> property is true.</param>
 public DoubleMappedFromBooleanOutput(IDoubleOutput targetOutput, double falseValue, double trueValue)
 {
     if (targetOutput == null)
     {
         throw new ArgumentNullException(nameof(targetOutput));
     }
     _targetOutput       = targetOutput;
     _falseValue         = falseValue;
     _trueValue          = trueValue;
     _targetOutput.Value = falseValue;
 }
示例#6
0
        /// <summary>
        /// Creates an instance given a quadratic and linear factor and an offset (y = ax² + bx + c).
        /// </summary>
        /// <param name="target">The target output which shall receive the scaled values.</param>
        /// <param name="quadraticCoefficient">The factor by which the square of the value will be used.</param>
        /// <param name="factor">The factor to scale the output.</param>
        /// <param name="offset">The offset to add to the output.</param>
        /// <remarks>Setting the <see cref="Value"/> will set the <paramref name="target"/> value to
        /// <see cref="Value"/> * <paramref name="factor"/> + <paramref name="offset"/>.</remarks>
        public DoubleScaledOutput(IDoubleOutput target, double quadraticCoefficient, double factor, double offset)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            _target = target;
            _quadraticCoefficient = quadraticCoefficient;
            _factor = factor;
            _offset = offset;
        }
示例#7
0
        /// <summary>
        /// Creates an instance.
        /// </summary>
        /// <param name="targetOutput">The target output to be smoothed.</param>
        /// <param name="valueChangePerSecond">The amount by that the <paramref name="targetOutput"/> value shall change
        /// per second in order to reach the <see cref="Value"/> property which definies the goal value.</param>
        /// <param name="rampIntervalMs">The interval, in milliseconds, in which the <paramref name="targetOutput"/>
        /// value shall be computed and set. The smaller this value, the more often and more smoothly will the target
        /// value be adapted.</param>
        public DoubleSmoothedOutput(IDoubleOutput targetOutput, double valueChangePerSecond, int rampIntervalMs)
        {
            _targetOutput = targetOutput ?? throw new ArgumentNullException(nameof(targetOutput));
            if (valueChangePerSecond <= 0.0)
            {
                throw new ArgumentOutOfRangeException(nameof(valueChangePerSecond));
            }
            if (rampIntervalMs <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(rampIntervalMs));
            }

            _valueChangePerTick = valueChangePerSecond / TimeSpan.TicksPerSecond;
            _rampIntervalMs     = rampIntervalMs;
        }
示例#8
0
 /// <summary>
 /// Creates a <see cref="DoubleScaledOutput"/> object which will scale values linear using a factor only and
 /// 0.0 as the offset.
 /// </summary>
 /// <param name="targetOutput">The target output to received the scaled values.</param>
 /// <param name="factor">The factor to use.</param>
 /// <returns>The created <see cref="DoubleScaledOutput"/> object.</returns>
 /// <remarks>The <paramref name="targetOutput"/> will receive values scaled by the formula:
 /// <see cref="IDoubleOutput.Value">Value</see> * <paramref name="factor"/>.</remarks>
 public static DoubleScaledOutput Scaled(this IDoubleOutput targetOutput, double factor)
 {
     return(new DoubleScaledOutput(targetOutput, factor));
 }