@Override protected void transform(int x, int y, double[] t) { int d = limitByte( (int) (127 * (1 + PerlinNoise.noise2D( ((double) x) / scale + randomX, ((double) y) / scale + randomY)))); t[0] = x + tx[d]; t[1] = y + ty[d]; }
protected void filter2(int[] inPixels, int[] outPixels, int width, int height) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int pixel = limitByte( (int) (127 * (1 + PerlinNoise.noise2D( ((double) x) / scale + randomX, ((double) y) / scale + randomY)))); outPixels[x + y * width] = (limitByte((int) 255) << 24) | (limitByte((int) pixel) << 16) | (limitByte((int) pixel) << 8) | (limitByte((int) pixel)); } } }
/** * @param b 0=central Neumann || 1=uVel || 2=vVel || 3=potTemp || 4=waterVapor || 5=cloudWater * @param f field to set boundaries */ public void setBounds(int b, float[][] f) { // b=0 central data neuman boundary if (b == 0) { for (int i = 1; i <= ssx; i++) { f[i][0] = f[i][1]; f[i][ssy + 1] = f[i][ssy]; } for (int i = 1; i <= ssy; i++) { f[0][i] = f[1][i]; f[ssx + 1][i] = f[ssx][i]; } } // b=1 u velocity // bottom = noslip // top = free slip // sides = user defined wind if (b == 1) { for (int i = 1; i <= ssy; i++) { // f[1][i] = -f[2][i]; f[0][i] = wind; f[1][i] = wind; // not sure wheter in or out f[ssx + 1][i] = wind; f[ssx][i] = wind; } for (int i = 1; i <= ssx; i++) { f[i][0] = 0; f[i][ssy + 1] = f[i][ssy]; } } // b=2 v // bottom = noslip // top = free slip // sides = zero if (b == 2) { for (int i = 1; i <= ssy; i++) { f[0][i] = 0; // if(i<(ssx/2-ssx/4) && i>(ssx/2+ssx/4)) // f[1][i] = 0; //not sure wheter in or out } for (int i = 1; i <= ssx; i++) { f[i][0] = 0; // if(i<(ssx/2-ssx/4) && i>(ssx/2+ssx/4)) f[i][1] = 0; // out for cloud input f[i][ssy + 1] = 0; } } // b=3 potential temp // set to initial values // bottom noise if (b == 3) { float pt0 = (float) (absT[0] * (Math.pow((p0 / absP[0]), 0.286))); for (int i = 0; i < ssx + 2; i++) { f[i][0] = pt0; if (i > (ssx / 2 - ssx / 4) && i < (ssx / 2 + ssx / 4)) { f[i][2] = pt0 + PerlinNoise.perlinNoise(i, time * 0.8f + 5000, 0.51f, 10f, 1f) * heatSrc; f[i][1] = pt0 + 0; } f[i][ssy + 1] = (float) (absT[ssy + 1] * Math.pow((100 / absP[ssy + 1]), 0.286)); } for (int j = 0; j < ssy + 2; j++) { f[0][j] = (float) (absT[j] * Math.pow((100 / absP[j]), 0.286)); f[ssx + 1][j] = (float) (absT[j] * Math.pow((100 / absP[j]), 0.286)); } } // b=4 water vapor // periodic sides // top = 0 // bottom = noise if (b == 4) { float qv0 = (float) (hum * ((380 / (absP[0] * 1000)) * Math.exp((17.67 * (absT[0] - 273.15)) / (absT[0] - 273.15 + 243.5)))); float qv1 = (float) (hum * ((380 / (absP[ssy + 1] * 1000)) * Math.exp( (17.67 * (absT[ssy + 1] - 273.15)) / (absT[ssy + 1] - 273.15 + 243.5)))); for (int i = 0; i < ssx + 2; i++) { f[i][ssy + 1] = qv1; f[i][0] = qv0; // PerlinNoise.perlinNoise(i, 50000000+time*0.8f, 0.51f, 10f, 1f)*0.9f; if (i > (ssx / 2 - ssx / 4) && i < (ssx / 2 + ssx / 4)) f[i][0] = 0.01f; // += 0.00041f; } for (int j = 0; j < ssy; j++) { f[1][j] = (float) (hum * ((380 / (absP[j] * 1000)) * Math.exp((17.67 * (absT[j] - 273.15)) / (absT[j] - 273.15 + 243.5)))); } } // b=5 cloud water // all to 0 if (b == 5) { for (int i = 0; i < ssy + 2; i++) { f[0][i] = 0; f[ssx + 1][i] = 0; } for (int i = 0; i < ssx + 2; i++) { f[i][0] = 0; f[i][ssy + 1] = 0; } } }