Game Development Reference
Excerpt from include/cyclone/particle.h
// ... Other Particle code as before ...
* Integrates the particle forward in time by the given amount.
* This function uses a Newton-Euler integration method, which is a
* linear approximation of the correct integral. For this reason it
* may be inaccurate in some cases.
void integrate(real duration);
Excerpt from src/particle.cpp
using namespace cyclone;
void Particle::integrate(real duration)
assert(duration > 0.0);
// Update linear position.
// Work out the acceleration from the force.
Vector3 resultingAcc = acceleration;
// Update linear velocity from the acceleration.
// Impose drag.
velocity *= real_pow(damping, duration);
I have added the integration method to the Particle class because it simply up-
dates the particles' internal data. It takes just a time interval and updates the position
and velocity of the particle, returning no data.