Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : Comparing intersection points of array object list

$
0
0
the bracket error was due to transfering over here. careless mistake.

heres the cellFast class:


  1. class cellFast{

  2.   final PVector location = new PVector(random(width), random(height));
  3.   final PVector velocity = new PVector();
  4.   final PVector acceleration = new PVector();
  5.   
  6.  final static float TOP_SPEED = 7;
  7.   final static short DIAM = 20;

  8.   final static short DIM = 5, MIN_DIST = 60, MAX_SPD = 6;
  9.  

  10.   
  11.     

  12.   void update1() {

  13.   PVector.random2D(acceleration).mult(noise(7));

  14.     velocity.add(acceleration);
  15.     velocity.limit(TOP_SPEED);

  16.     location.add(velocity);
  17.   }

  18.   void displayFast() {
  19.     
  20.  stroke(0);
  21.     strokeWeight(2);
  22.     fill(0200);
  23.     ellipse(location.x, location.y, DIAM, DIAM);

  24.   }
  25.   


  26.   void checkEdges1() {


  27.    if (location.x > width)   location.x = 0;
  28.     else if (location.x < 0)  location.x = width;

  29.     if (location.y > height)  location.y = 0;
  30.     else if (location.y < 0)  location.y = height;
  31.     
  32.  
  33. }

  34.  boolean isNear(cellFast other) {
  35.     //return dist(x, y, other.x, other.y) < MIN_DIST;
  36.     //return sq(abs(other.x - x)) + sq(abs(other.y - y)) < MIN_DIST*MIN_DIST;
  37.     
  38.     return abs(other.location.x - location.x) < MIN_DIST 
  39.       && abs(other.location.y - location.y) < MIN_DIST;
  40.   }

  41.   void drawLine(cellFast other) {
  42.     stroke(4);
  43.     line(location.x, location.y, other.location.x, other.location.y);
  44. location.x += 3; //move opposite direction to not intersect
  45.     location.y += random(5);
  46. }

  47. }

Viewing all articles
Browse latest Browse all 1768

Trending Articles