import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.applet.*; public class StableFluids extends Applet implements Runnable,MouseListener,MouseMotionListener { final int size = 128; final int mask = size-1; double[][] c = new double[size][size]; double[][] u = new double[size][size]; double[][] v = new double[size][size]; double[][] tmp_c = new double[size][size]; double[][] tmp_u = new double[size][size]; double[][] tmp_v = new double[size][size]; double[][] p = new double[size][size]; double[][] rec_lap = new double[size][size]; double[][] im = new double[size][size]; boolean dragging = false; double mouseX,mouseY; double cursorX,cursorY; double cursorU,cursorV; FFT fft; int scale = 4; int[] pixels = new int[size*size]; MemoryImageSource mis; Image image; Thread thread; public void update(Graphics g) { paint(g); } public void paint(Graphics g) { for (int i=0,y=0;y>= 1; if ((a&i)!=0) c |= b; b <<= 1; } perm[i] = c; } } private void permute(double[] re,double[] im) { for (int i=0;ii) { double tmp_re = re[i]; double tmp_im = im[i]; re[i] = re[perm[i]]; im[i] = im[perm[i]]; re[perm[i]] = tmp_re; im[perm[i]] = tmp_im; } } public void forward(double[] re,double[] im) { permute(re,im); for (int i=0;i>=1) for (int i=0;i>=1) for (int i=0;i