# Help me understand this cool/short code on OpenProcessing

**URL:** <https://discourse.processing.org/t/help-me-understand-this-cool-short-code-on-openprocessing/13721>\
**Category:** Coding Questions\
**Created:** [August 31, 2019, 1:12pm UTC](https://discourse.processing.org/t/help-me-understand-this-cool-short-code-on-openprocessing/13721 "2019-08-31T13:12:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sorenkirk](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@sorenkirk](https://discourse.processing.org/u/sorenkirk)\
**Post date:** [August 31, 2019, 1:12pm UTC](https://discourse.processing.org/t/help-me-understand-this-cool-short-code-on-openprocessing/13721/1 "2019-08-31T13:12:35Z")

</div>

I found the following code on Open Processing.

[https://www.openprocessing.org/sketch/374455](https://www.openprocessing.org/sketch/374455)

Would somebody help me understand the Particle class? In particular, what is the math going on in the `update` function?

```auto
class Particle{
  
  PVector pos, vel;
  float saturation;
  
  Particle(){
    float posAng = random(TWO_PI);
    float posSize = random(maxRadious);
    pos = new PVector(posSize * cos(posAng), posSize * sin(posAng));
    float velAng = random(TWO_PI);
    float velSize = random(minVel, maxVel);
    vel = new PVector(velSize * cos(velAng), velSize * sin(velAng));
    saturation = random(100);
  }
  
  void update(){
    pos.add(vel);
    if(pos.mag() > maxRadious){
      pos.limit(maxRadious);
      float posAng = atan2(pos.y, pos.x);
      float velAng = atan2(vel.y, vel.x);
      float velSize = vel.mag();
      vel.x = velSize * cos(2 * posAng - velAng - PI);
      vel.y = velSize * sin(2 * posAng - velAng - PI);
    }
  }
}

```
