How to generate particles in a wave shaped grid (Rayleigh surface waves)

image alt text psu.edu/Rayleigh surface waves

i want to achieve this kind of generated pattern to generate a wave grid. Since its a wave it needs a Sin but there is also a change in horizontal spacing and vertical amplitude.

What kind of formulae should i looking for?

what i got so far is:

  int x; 
  int y;
  int w = 5;
  int h = 5;

  int col = -1;
  int row = 0; 

void setup() 
{
  size (500, 500);
  frameRate(10);
}

void draw() 
{
  if (row>=11) return; // finished
  if (++col>=28) { row++; col=0; }
  pushMatrix();
  translate(100,100);
      x = col*10; y = row*10 + round(5*sin(x));
      print(sin(row)+" ");
      ellipse(x,y,w,h);
  popMatrix();
}

Answers

  • edited December 2013

    I'll begin by giving out a hint. That's all I can do at the moment.

    Notice that the topmost particles move in a circle, and the lower they get, the more oval-ish their trajectory gets.

  • Just tweak it a little bit for your purpose

    ArrayList<Ring> poop = new ArrayList();
    
    void setup() {
      size(600, 600);
      for (int x=0;x<20;x++) {
        for (int y=0;y<20;y++) {
          int index = x +y*10;
          Ring R = new Ring(x*30, y*30, index, 20);
          poop.add(R);
        }
      }
    }
    
    void draw() {
      background(-1);
      translate(mouseX,mouseY);
      rotate(PI/2);
      for (int i=0;i<poop.size();i++)
      {
        Ring r = (Ring) poop.get(i);
        r.display();
        r.update();
      }
    }
    
    
    class Ring {
      int h, k, rad;
      float i, v;
      Ring(int h, int k, int i, int rad) {
        this.h = h;
        this.k = k;
        this.rad = rad;
        v = random(0.5, 2);
        this.i = i;
      }
    
      void display() {
        float x = h+rad*sin(radians(i));
        float y = k+rad*cos(radians(i));
        noStroke();
        fill(0);
        ellipse(x, y, 10, 10);
      }
    
    
      void update() {
        i=i+2;
        if (i>360)i=0;
      }
    }
    
Sign In or Register to comment.