title: Detecting line's intersections
body: <p>I am trying to solve this problem: drawing random lines on the screen then create dots at intersection of all the lines. My solution: instead of creating real lines, I use little dots to construct lines. Each "line" is an instance of a class called Pointe.  I store all the coordinates of each line instance in it's own array. In order to detect intersection, I wrote function collide() to compare each line's stored coordinates. If the distance &lt;10, I change the line's thickness to 10 pixel to create the "balloon" effect.</p>
  
  <pre><code>int p = 0;
  class Pointe {
    int x;
    int y;
    int speedX;
    int speedY;
    float size = 2;
    color c = color(random(255),random(255),random(255));
    int position_stored[] = {};
    Pointe(int xPosition, int yPosition, int speed_X, int speed_Y) {
      x = xPosition;
      y= yPosition;
      speedX = int(random(speed_X));
      speedY = int(random(speed_Y));
    }
  
    int b = int(mouseX);
    int n = int(mouseY);
  
    void move() {
      x = x + speedX;
      y = y + speedY;
      if (x&gt;60) {x = x; y = y;}
      if (y&gt;60) {y = y; x = x;}
      store_position();
    }
  
    void display() {
      noStroke();
      fill(c);
      ellipse(x,y,size,size);
    }
    int getX() {return x;}
    int getY() {return y;}
    void store_position() {
      int position_stored2[] = append(position_stored,getX());
      int position_stored3[] = append(position_stored2,getY());
      position_stored = position_stored3;
    }
  
    void collide(int[] a) {
      for (int i = 1; i &lt; a.length ; i=i+2) {
          int distance = int(dist(x,y,a[i-1],a[i])); 
          if (distance &lt; 20) {size = 10;}
          else {size = 2;}
      }
    }
  }
  int number = 109;
  void setup(){
    size(600,600);
    background(255);
    for (int i = 0; i &lt;number; i++) {
      points[i] = new Pointe(int(random(600)),int(random(600)),int(random(-6,6)),int(random(-6,6)));
    }
  }
  
  Pointe[] points =  new Pointe[number];
  
  void draw(){
    for (int i = 0; i &lt;number; i++) {
      for (int z = 0; z &lt;number; z++) {
        if (i == z) {}
        points[i].collide(points[z].position_stored);
      }
      points[i].display();
      points[i].move();   
    }
  }
  </code></pre>