Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › Bouncing Ball Expression

  • Bouncing Ball Expression

    Posted by Chris Petri on December 4, 2013 at 11:37 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.
    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 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

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