class Ball { /// add a force to the ball // // Force = Mass * Acc // // Acceleration = Force / Mass // ///////////////////////////////// Vector3D loc; Vector3D vel; Vector3D acc; Vector3D screenLoc; // location to store screen positions after translation. //// add target positions to move to //// Vector3D t; float mass; float max_vel; float w_top; // 'upper' width of ball float w_base; Vector3D edge_top; // co-ordinates where the widht of the ball, in given direction touches it's cirumference Vector3D edge_base; //float w_deviation; /////////////////////////////////////////////////////////////// Ball (Vector3D loc_) { loc = loc_; t = new Vector3D (loc.x, loc.y); // store the target as it's original location // this could be updated ?? //w = 4;//random (4); vel = new Vector3D (0, 0, 0); acc = new Vector3D (0, 0, 0); mass = 1.5; max_vel = 2;//.2; screenLoc = new Vector3D (loc.x, loc.y, 0); edge_top = new Vector3D (0, 0); edge_base = new Vector3D (0, 0); } // each ball has it's own force being added to it. void addForce (Vector3D force) { // FORCE = MASS * ACCELERATION; // ACCELERATION = FORCE / MASS; force.div (mass); acc.add (force); } /////////////////////////////////// ///////// add methods to update location according to velocity and acceleration //////// void update () { vel.add(acc); vel.limit(max_vel); loc.add(vel); acc.setXYZ(0.0,0.0,0.0); } ////// ////////////////////////////////////////////// void drawBall () { ellipse (0, 0, w_base, w_base); } //////////////////////////////////////////// }