#include "assert.h"
#include "particle.hpp"

namespace physics {

  void particle::integrate(float duration)
  {
    assert(duration > 0.0f);

    // linear position
    position += velocity * duration;

    // acceleration from force
    vec3 acc = acceleration + force_accum * inverse_mass;

    // linear velocity
    velocity += acc * duration;

    // drag
    velocity *= damping;

    // clear forces
    force_accum = vec3(0, 0, 0);
  }

}
