using System; using System.Diagnostics; namespace LibNoise.Operator { /// /// Provides a noise module that maps the output value from a source module onto an /// exponential curve. [OPERATOR] /// public class Exponent : ModuleBase { #region Fields private double _exponent = 1.0; #endregion #region Constructors /// /// Initializes a new instance of Exponent. /// public Exponent() : base(1) { } /// /// Initializes a new instance of Exponent. /// /// The input module. public Exponent(ModuleBase input) : base(1) { Modules[0] = input; } /// /// Initializes a new instance of Exponent. /// /// The exponent to use. /// The input module. public Exponent(double exponent, ModuleBase input) : base(1) { Modules[0] = input; Value = exponent; } #endregion #region Properties /// /// Gets or sets the exponent. /// public double Value { get { return _exponent; } set { _exponent = 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); var v = Modules[0].GetValue(x, y, z); return (Math.Pow(Math.Abs((v + 1.0) / 2.0), _exponent) * 2.0 - 1.0); } #endregion } }