FORUMS: list search recent posts

# Bouncing Ball Expression

FAQ   •   VIEW ALL
 Bouncing Ball Expression on Dec 4, 2013 at 11:37:34 pm

Hey guys,
If got a litte problem with the bouncing-ball expression by Dan Ebberts.
A Ball gets shot with a defined velocity(v) and a Launch angle (elev). When it hits the floor, it bounces several times before it reaches its end-position.
I want to define a floor which the ball uses for bouncing after it got shot. The floor has to sit lower than the start position. The Y-Value doesnt need to be linked to a seperate floor layer. It works for me if I can define the value in the expression.
I´m sure this issue can be fixed with a just a little extra code but I don`t get it.
```elev = degreesToRadians(75); //launch angle v = 1900; // velocity e = .7; //elasticity f = .5; // friction g = 5000; //gravity nMax = 9; // maximum number of bounces tLaunch = 1; // Launch-time vy = v*Math.sin(elev); vx = v*Math.cos(elev); if (time >= tLaunch){ t = time - tLaunch; tCur = 0; segDur = 2*vy/g; tNext = segDur; d = 0; // x distance traveled nb = 0; // number of bounces while (tNext < t && nb <= nMax){ d += vx*segDur; vy *= e; vx *= f; segDur *= e; tCur = tNext; tNext += segDur; nb++ } if(nb <= nMax){ delta = t - tCur; x = d + delta*vx; y = delta*(vy - g*delta/2); }else{ x = d; y = 0; } value + [x,-y] }else value ```