/** * @param octaves the number of octaves to use */ public BrownianNoise2D(Noise2D other, int octaves) { this(other); setOctaves(octaves); }
/** * Returns Fractional Brownian Motion at the given position. * * @param x Position on the x-axis * @param y Position on the y-axis * @return The noise value in the range [-getScale()..getScale()] */ @Override public float noise(float x, float y) { float result = 0.0f; float workingX = x; float workingY = y; for (int i = 0; i < getOctaves(); i++) { result += other.noise(workingX, workingY) * (float) getSpectralWeight(i); workingX *= (float) getLacunarity(); workingY *= (float) getLacunarity(); } return result; }