Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects › Bouncing Ball Expression

  • Bouncing Ball Expression

    Posted by Chris Petri on December 4, 2013 at 5:48 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;
    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

    Chris Petri replied 12 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • John Cuevas

    December 4, 2013 at 6:48 pm

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

    Johnny Cuevas, Editor
    Thinkck.com

    “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.

  • Chris Petri

    December 4, 2013 at 11:29 pm

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

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy