Particles moving around a Perlin Noise field I made this sketch in Processing (basically Java) that consists of a bunch of particles moving around a Perlin Noise field. Each particle is aware of the position of one other particle and this creates a rope like effect. The sketch is intended to be aesthetic, like a screensaver, and I in that way it might be difficult to judge the efficiency of the code. 

Nevertheless, I'm hoping that there is something that I'm doing wrong stylistically that could be pointed out.

    int emergenceInterval = int(random(75, 100));
    float a, freq = 0.05;
    float alphDelta, alphAccel, alphSpringing = 0.0009, alphDamping = 0.98, alphX, maxAlph;
    int pAmt = int(random(2000, 4000));
    Particle p[] = new Particle[pAmt]; 

    void setup() {
      background(0);
      size(1000, 500); 
      for (int i = 0; i &lt; pAmt; i++) {
        p[i] = new Particle(random(width), random(height), i);
      }
    }

    void draw() {
      if(frameCount % emergenceInterval == 0) {
       if(maxAlph == .05) maxAlph = 1;
       else maxAlph = .05; 
      }
      a += freq;
      fill(50, findAlpha() * 255);
      rect(0, 0, width, height);
      runParticles();
    }

    void runParticles() {
      for (Particle _p : p) {
        Particle lastP = _p;
        if (_p.index != 0) lastP = p[_p.index - 1];
        _p.update(450, lastP.pos, abs(pow(sin(radians(a)), 3)));
        point(_p.pos.x, _p.pos.y);
        _p.vel.x = 1;
      }
    }

    float findAlpha() {
      if (!(alphAccel &lt; 0)) alphDelta = width - alphX;
      else alphDelta = 0 - alphX;
      alphDelta *= alphSpringing;
      alphAccel += alphDelta;
      alphAccel *= alphDamping;
      alphX += alphAccel;
      float alph = (alphX * (maxAlph * abs(pow(sin(radians(a)), 2))))/width;

      if(alphX &gt; width) alphAccel *= -1;
      else if(alphX &lt; 0) alphAccel *= -1;
      return alph;
    }


  class Particle {

  int index;
  float theta;
  float stride;
  float maxSpeed = 5;
  float maxChaos = 10;
  PVector accel, vel, pos;


  Particle(float startX, float startY, int index) {
    this.index = index;
    accel = new PVector(0, 0);
    vel = new PVector(0, 0);
    pos = new PVector(startX, startY);
  } 

  void update(float stride, PVector target, float chaos) {
    this.stride = stride;
    stroke(50*(noise(pos.x)),0,50*(noise(pos.x)), noise(pos.x, pos.y) * 255);
    accel = noiseDir(chaos);
    accel.add(followDir(target));
    if (pos.x &gt; width) pos.x = 0;
    if (pos.y &gt; height) pos.y = 0;
    if (pos.y &lt; 0) pos.y = height;
    vel.add(accel);
    float speed = noise(pos.x, pos.y) * maxSpeed;
    vel.limit(speed);
    pos.add(vel);
  }

  PVector noiseDir(float chaos) {
    theta = abs(noise(pos.x, pos.y)) * 180;
    float x = pos.x + stride * cos(theta);
    float y = pos.y + stride * sin(theta);
    PVector dir = new PVector(x - pos.x, y - pos.y);
    dir.normalize();
    dir.mult(chaos * maxChaos);
    return dir;
  }

  PVector followDir(PVector target) {
    PVector dir = new PVector(target.x - pos.x, target.y - pos.y);
    dir.normalize();
    dir.mult(5);
    return dir;
  }
}
(1). From the point of style I'd recommend you not to mix the level of details in a function. For example.

Instead of writing something like this:

void setup() {
  background(0);
  size(1000, 500); 
  for (int i = 0; i &lt; pAmt; i++) { // this is bad
    p[i] = new Particle(random(width), random(height), i);
  }
}


You should write something like this. The same is applicable for other functions.

void setup() {
  background(0);
  size(1000, 500); 
  fillArray(); // there goes the loop and it's load easier to read.
}


(2). As for naming conventions I'd recommend you to use a verb as a first part for the function's name. Code like this looks unusual.

background(0);
size(1000, 500); 


(3). You should be consistent with names for your variables. For example in your update() function you can see a mix of full and short names like stride, target, chaos vs accel, vel, pos. It really makes me think a lot more about names than I should.

(4).If you have to call this "normalize()" method a lot after construction of the object I'd recommend to think about adding this method to consturctor for example with the flag called "shouldNormalize".

PVector dir = new PVector(x - pos.x, y - pos.y);
dir.normalize();


vs

PVector dir = new PVector(x - pos.x, y - pos.y, true); 
//or make it to normalize the vector by default and pass false when you don't need it
//but I guess that you should normalize it quite often after creation  


(5). I would strongly recommend to make Particle class immutable. It would save you from a lot of hacks like this and make your code cleaner:

 void update(float stride, PVector target, float chaos) {
 this.stride = stride;
 ... }