using System; namespace LibNoise.Generator { /// /// Provides a noise module that outputs a checkerboard pattern. [GENERATOR] /// public class Checker : ModuleBase { #region Constructors /// /// Initializes a new instance of Checker. /// public Checker() : base(0) { } #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) { var ix = (int) (Math.Floor(Utils.MakeInt32Range(x))); var iy = (int) (Math.Floor(Utils.MakeInt32Range(y))); var iz = (int) (Math.Floor(Utils.MakeInt32Range(z))); return (ix & 1 ^ iy & 1 ^ iz & 1) != 0 ? -1.0 : 1.0; } #endregion } }