ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Bouncing Ball Expression

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Chris Petri
Bouncing Ball Expression
on Dec 4, 2013 at 5:48:09 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". This floor has to sit lower than the start position
I´m sure this issue can be fixed with a just a little extra code but I don`t get it.
Thanks in advance!

Here´s the expression:

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;
if(nb <= nMax){
delta = t - tCur;
x = d + delta*vx;
y = delta*(vy - g*delta/2);
x = d;
y = 0;
value + [x,-y]

Return to posts index

John Cuevas
Re: Bouncing Ball Expression
on Dec 4, 2013 at 6:48:51 pm

Dan reads and posts in the Expressions Forum all the time, you might want to post over there...

Johnny Cuevas, Editor

"I have not failed 700 times. I have succeeded in proving that those 700 ways will not work. When I have eliminated the ways that will not work, I will find the way that will work."
---THOMAS EDISON on inventing the light bulb.

Return to posts index

Chris Petri
Re: Bouncing Ball Expression
on Dec 4, 2013 at 11:29:49 pm

Oh okay sorry, didnt see that there are also sub-categorys, thanks

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved