Integrals: How Game Engines Accumulate Change

Integrals accumulate values over time or space. In game engines, this means calculating total distance from velocity, damage over time, or areas for lighting calculations.

The Mathematical Definition

An integral accumulates tiny pieces:

This represents the area under the curve f(x) from point a to point b.

Game Engine Applications

Position from Velocity

If you know velocity over time, integration gives you total distance:

Damage Over Time

// Constant damage rate
float totalDamage = damageRate * (endTime - startTime);
 
// Variable damage rate (numerical integration)
float totalDamage = 0;
for (float t = startTime; t < endTime; t += deltaTime) {
    totalDamage += getDamageRate(t) * deltaTime;
}

Euler Integration in Physics

struct Particle {
    Vector3 position, velocity, acceleration;
    float mass;
};
 
void updatePhysics(Particle& p, float deltaTime) {
    // Integrate acceleration to get velocity
    p.velocity += p.acceleration * deltaTime;
    
    // Integrate velocity to get position  
    p.position += p.velocity * deltaTime;
}