/// <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); }