Example #1
0
        /// <inheritdoc />
        public double Noise(INoise1D sourceNoise, double x)
        {
            INoiseDistorter1DContracts.Noise(sourceNoise);

            return(this.distorter.Noise(sourceNoise, x).ConvertRange(
                       this.sourceNoiseStart, this.sourceNoiseEnd, this.resultNoiseStart, this.resultNoiseEnd));
        }
Example #2
0
        public DistortedNoise1D(INoise1D noise, INoiseDistorter1D distorter)
        {
            Contracts.Requires.That(noise != null);
            Contracts.Requires.That(distorter != null);

            this.noise     = noise;
            this.distorter = distorter;
        }
        /// <inheritdoc />
        public double Noise(INoise1D sourceNoise, double x)
        {
            INoiseDistorter1DContracts.Noise(sourceNoise);

            double result = 0;

            foreach (var distorter in this.distorters)
            {
                result += distorter.Noise(sourceNoise, x);
            }

            return(result);
        }
        /// <inheritdoc />
        public double Noise(INoise1D sourceNoise, double x)
        {
            INoiseDistorter1DContracts.Noise(sourceNoise);

            double result = this.distorter.Noise(sourceNoise, x);

            int weight = 2;

            for (int octave = 2; octave <= this.numberOfOctaves; octave++)
            {
                result += this.distorter.Noise(sourceNoise, x * weight) / weight;
                weight *= 2;
            }

            return(result);
        }
        /// <summary>
        /// Provides extension methods various types within Heirloom.
        /// </summary>
        public static float Sample(this INoise1D noise, float x, int octaves, float persistence = 0.5F)
        {
            var total     = 0F;
            var frequency = 1F;
            var amplitude = 1F;
            var maxValue  = 0F;

            for (var i = 0; i < octaves; i++)
            {
                total += noise.Sample(x * frequency) * amplitude;

                maxValue += amplitude;

                amplitude *= persistence;
                frequency *= 2;
            }

            return(total / maxValue);
        }
Example #6
0
        /// <inheritdoc />
        public double Noise(INoise1D sourceNoise, double x)
        {
            INoiseDistorter1DContracts.Noise(sourceNoise);

            return(this.distorter.Noise(sourceNoise, x + this.xShift));
        }
Example #7
0
        /// <inheritdoc />
        public double Noise(INoise1D sourceNoise, double x)
        {
            INoiseDistorter1DContracts.Noise(sourceNoise);

            return(this.distorter.Noise(sourceNoise, x) * this.amplitude);
        }
        /// <inheritdoc />
        public double Noise(INoise1D sourceNoise, double x)
        {
            INoiseDistorter1DContracts.Noise(sourceNoise);

            return(this.distorter.Noise(sourceNoise, x * this.xFrequency));
        }
 public static void Noise(INoise1D sourceNoise)
 {
     Contracts.Requires.That(sourceNoise != null);
 }
Example #10
0
        /// <inheritdoc />
        public double Noise(INoise1D sourceNoise, double x)
        {
            INoiseDistorter1DContracts.Noise(sourceNoise);

            return(sourceNoise.Noise(x));
        }
Example #11
0
 public Noise1DDebugger(INoise1D noise)
 {
     _noise = noise;
 }
Example #12
0
        /// <inheritdoc />
        public double Noise(INoise1D sourceNoise, double x)
        {
            INoiseDistorter1DContracts.Noise(sourceNoise);

            return(this.distorter.Noise(sourceNoise, x).Clamp(this.min, this.max));
        }