class Particle { Vector3D loc; Vector3D vel; Vector3D acc; float theta; float theta_vel; float theta_acc; float particleSize; float x,y; Particle(Vector3D loc_, Vector3D vel_, float theta) { loc = loc_.copy(); vel = vel_.copy(); acc = new Vector3D(0,0); float x = loc.x * sin(theta); float y = loc.y * cos(theta); // is this good habit to call a class from another class? loc = new Vector3D(magnet.getLoc().x + x, magnet.getLoc().y + y); theta = 0.0f; theta_vel = 0.0f; particleSize = 1.0f; } public Vector3D getLoc() { return loc; } void calcForce(float amplitude_) { /*float G = 0.4; // universal gravity float dist = Vector3D.distance(loc,magnet.getLoc()); //println(dist); theta_acc = ( G / amplitude_ ) * sin(theta); theta_vel += theta_acc + 0.005; theta += theta_vel; // println(theta); // loc.add(vel); x = dist * sin(theta); y = dist * cos(theta); loc.x = magnet.getLoc().x + x; loc.y = magnet.getLoc().y + y;*/ } void changeColor() { float dist = Vector3D.distance(magnet.loc,loc); fill(dist,255-dist,255); } void run() { vel.add(acc); loc.add(vel); acc.setXYZ(0,0,0); } void add_force(Vector3D v) { acc.add(v); } void render() { //stroke(255,50); ellipseMode(CENTER); //stroke(255); // println(disp.x); noStroke(); ellipse(loc.x, loc.y,3,3); fill(0,0,0,20); ellipse(loc.x, loc.y,10,10); } }