From 256d4b2d66ce7cbb765ffe77d19b0482f6f89714 Mon Sep 17 00:00:00 2001 From: "Ricardo J. Mendez" Date: Thu, 24 Jul 2014 10:13:27 +0300 Subject: [PATCH] Removed unnecessary backing fields from ScaleBias --- Operator/ScaleBias.cs | 170 +++++++++++++++++++----------------------- 1 file changed, 78 insertions(+), 92 deletions(-) diff --git a/Operator/ScaleBias.cs b/Operator/ScaleBias.cs index e4e9b28..8da7799 100755 --- a/Operator/ScaleBias.cs +++ b/Operator/ScaleBias.cs @@ -1,93 +1,79 @@ -using System.Diagnostics; - -namespace LibNoise.Operator -{ - /// - /// Provides a noise module that applies a scaling factor and a bias to the output - /// value from a source module. [OPERATOR] - /// - public class ScaleBias : ModuleBase - { - #region Fields - - private double _scale = 1.0; - private double _bias; - - #endregion - - #region Constructors - - /// - /// Initializes a new instance of ScaleBias. - /// - public ScaleBias() - : base(1) - { - } - - /// - /// Initializes a new instance of ScaleBias. - /// - /// The input module. - public ScaleBias(ModuleBase input) - : base(1) - { - Modules[0] = input; - } - - /// - /// Initializes a new instance of ScaleBias. - /// - /// The scaling factor to apply to the output value from the source module. - /// The bias to apply to the scaled output value from the source module. - /// The input module. - public ScaleBias(double scale, double bias, ModuleBase input) - : base(1) - { - Modules[0] = input; - Bias = bias; - Scale = scale; - } - - #endregion - - #region Properties - - /// - /// Gets or sets the bias to apply to the scaled output value from the source module. - /// - public double Bias - { - get { return _bias; } - set { _bias = value; } - } - - /// - /// Gets or sets the scaling factor to apply to the output value from the source module. - /// - public double Scale - { - get { return _scale; } - set { _scale = value; } - } - - #endregion - - #region ModuleBase Members - - /// - /// Returns the output value for the given input coordinates. - /// - /// The input coordinate on the x-axis. - /// The input coordinate on the y-axis. - /// The input coordinate on the z-axis. - /// The resulting output value. - public override double GetValue(double x, double y, double z) - { - Debug.Assert(Modules[0] != null); - return Modules[0].GetValue(x, y, z) * _scale + _bias; - } - - #endregion - } +using System.Diagnostics; + +namespace LibNoise.Operator +{ + /// + /// Provides a noise module that applies a scaling factor and a bias to the output + /// value from a source module. [OPERATOR] + /// + public class ScaleBias : ModuleBase + { + #region Constructors + + /// + /// Initializes a new instance of ScaleBias. + /// + public ScaleBias() + : base(1) + { + Scale = 1; + } + + /// + /// Initializes a new instance of ScaleBias. + /// + /// The input module. + public ScaleBias(ModuleBase input) + : base(1) + { + Modules[0] = input; + Scale = 1; + } + + /// + /// Initializes a new instance of ScaleBias. + /// + /// The scaling factor to apply to the output value from the source module. + /// The bias to apply to the scaled output value from the source module. + /// The input module. + public ScaleBias(double scale, double bias, ModuleBase input) + : base(1) + { + Modules[0] = input; + Bias = bias; + Scale = scale; + } + + #endregion + + #region Properties + + /// + /// Gets or sets the bias to apply to the scaled output value from the source module. + /// + public double Bias { get; set; } + + /// + /// Gets or sets the scaling factor to apply to the output value from the source module. + /// + public double Scale { get; set; } + #endregion + + #region ModuleBase Members + + /// + /// Returns the output value for the given input coordinates. + /// + /// The input coordinate on the x-axis. + /// The input coordinate on the y-axis. + /// The input coordinate on the z-axis. + /// The resulting output value. + public override double GetValue(double x, double y, double z) + { + Debug.Assert(Modules[0] != null); + return Modules[0].GetValue(x, y, z) * Scale + Bias; + } + + #endregion + } } \ No newline at end of file