using System.Diagnostics;
namespace LibNoise.Operator
{
///
/// Provides a noise module that scales the coordinates of the input value before
/// returning the output value from a source module. [OPERATOR]
///
public class Scale : 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 Scale.
///
public Scale()
: base(1)
{
}
///
/// Initializes a new instance of Scale.
///
/// The input module.
public Scale(ModuleBase input)
: base(1)
{
Modules[0] = input;
}
///
/// Initializes a new instance of Scale.
///
/// The scaling on the x-axis.
/// The scaling on the y-axis.
/// The scaling on the z-axis.
/// The input module.
public Scale(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 scaling factor on the x-axis.
///
public double X
{
get { return _x; }
set { _x = value; }
}
///
/// Gets or sets the scaling factor on the y-axis.
///
public double Y
{
get { return _y; }
set { _y = value; }
}
///
/// Gets or sets the scaling factor 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
}
}