Ross Borchers 🎮

Useful Game Math

Some math I find useful.

Sinusoidal pulse at a regular interval

Pulse visualization

Application of domain repetition to produce arbitrary gaps between a function (in this case sin).

float RepeatPulse(float t, float duration, float height, float interval)
    float tLocal = mod(t-duration, interval)-(interval-duration);
    float s = sin((tLocal/duration)*TWO_PI - PI/2.)/2.+.5;
    return s * height * ceil(clamp(tLocal, 0., 1.));

- 1 toast