using System.Diagnostics; namespace LibNoise.Operator { /// /// Provides a noise module that moves the coordinates of the input value before /// returning the output value from a source module. [OPERATOR] /// public class Translate : ModuleBase { #region Fields private double _x = 1.0; private double _y = 1.0; private double _z = 1.0; #endregion #region Constructors /// /// Initializes a new instance of Translate. /// public Translate() : base(1) { } /// /// Initializes a new instance of Translate. /// /// The input module. public Translate(ModuleBase input) : base(1) { Modules[0] = input; } /// /// Initializes a new instance of Translate. /// /// The translation on the x-axis. /// The translation on the y-axis. /// The translation on the z-axis. /// The input module. public Translate(double x, double y, double z, ModuleBase input) : base(1) { Modules[0] = input; X = x; Y = y; Z = z; } #endregion #region Properties /// /// Gets or sets the translation on the x-axis. /// public double X { get { return _x; } set { _x = value; } } /// /// Gets or sets the translation on the y-axis. /// public double Y { get { return _y; } set { _y = value; } } /// /// Gets or sets the translation on the z-axis. /// public double Z { get { return _z; } set { _z = 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 + _x, y + _y, z + _z); } #endregion } }