void Ball::setVelocity(GLfloat vx, GLfloat vy) { v.x[0] = vx; v.x[1] = vy; a[0] = find_accel(v.x[0]); a[1] = find_accel(v.x[1]); }
void Ball::update(float elapsed_time) { for (int i = 0; i < 2; i++) { x[i] = find_position(a[i], elapsed_time, v[i], x[i]); v.x[i] = find_velocity(a[i], elapsed_time, v[i]); a[i] = find_accel(v[i]); } checkBounds(); }
void move_particles (std::vector <Particle> *particles, std::vector <double> *field) { auto num_particles = particles->size(); std::vector <double> weights (2); std::vector <int> points (2); for (auto& particle : *particles) { if (CIC){ weighing (&particle, &weights[0]); } else if (ZERO_ORDER){ zero_order_weighing (&particle, &weights[0]); } adjacent_points (&particle, &points[0]); auto left_field = field->at (points [0]) * weights [0]; auto right_field = field->at (points [1]) * weights [1]; auto accel_0 = find_accel(left_field + right_field, &particle); particle.inc_pos (accel_0); if (CIC){ weighing (&particle, &weights[0]); } else if (ZERO_ORDER){ zero_order_weighing (&particle, &weights[0]); } adjacent_points (&particle, &points[0]); left_field = field->at (points [0]) * weights [0]; right_field = field->at (points [1]) * weights [1]; auto accel_1 = find_accel(left_field + right_field, &particle); particle.inc_vel (accel_0, accel_1); } }