 # Exponential Impulse not working

I’m working on this page:
http://www.iquilezles.org/www/articles/functions/functions.htm

And I try to get Exponential Impulse to work:

Exponential Impulse

Great for triggering behaviours or making envelopes for music or animation, and for anything that grows fast and then slowly decays. Use k to control the stretching of the function. Btw, its maximum, which is 1, happens at exactly x = 1/k.

``````float expImpulse( float k, float x ) {
const float h = k*x;
return h*exp(1.0-h);
}
`````` This is what I have, but it is all being zero.

``````

void setup() {
size(600, 600, P2D);
}

void draw() {
background(0);
stroke(255);
for (int x = 0; x < width; x++) {
float y = expImpulse(norm(mouseX, 0, width), x);
}
}

float expImpulse( float k, float x ) {
float h = k*x;
return h*exp(1.0-h);
}
``````

Can someone help?

1 Like

your code not draw or print anything,
but with this i see something:

``````void draw() {
background(0);
stroke(255);
for (int x = 0; x < width; x++) {
float y = expImpulse(norm(mouseX, 0, width), x);
point(x,height*(1-y));
}
}

``````
1 Like

Classic – forgetting to draw the point. I’ve done that. Give the input range, have to hover the mouse near the left edge to get interesting results.

O damn, to much scoped in on the wrong part…