1
\$\begingroup\$

I'm trying to build a bouncing-ball effect, and a newbie to calculus things...

For the ball-drop, it's straightforward - since there's no initial velocity and acceleration is constant.

For the bounce-up, it seems that what I want to do is integrate the velocity changes over time (since there's some transfer of energy upon impact, and that drives the ball upwards with a sortof fade-off as it fights against gravity?)

This leads me to some questions, one generic and one specific (with a more detailed followup):

  1. Is this correct- that I need to use integration and not just a straight kinematic equation for the bounce-up?

  2. I'm not quite sure about the difference between integration and accumulation. Ideally I would like to have a function y = f(t) where various other properties are known such as the initial velocity upon impact, but I do not want to accumulate anything every tick. I.e. it'd be nice to just have a pure function that pre-loads all the info it needs on impact, and then can be run with any time as an input. Can someone please explain the difference between integration and accumulation in light of this?

  3. A bit more specifically, it seems like maybe there are rules of integration that allow for solving at any t such as the "power rule", but then integrators like Euler/Verlet operate more like accumulators. This is confusing and speaks to the above point.

Thanks!

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

1) It's possible to use a kinematic equation for the bounce-up in the case of a perfectly elastic bounce -- just model the ball's motion as y = max_height - ((t - t_start) % (2 * sqrt(max_height)) - sqrt(max_height)) ** 2, for example.

enter image description here

2) Accumulation is a numeric approximation to integration. Any integral can be expressed as a series of sums of f(x) * dx where dx approaches 0. The standard game-engine accumulation pattern uses an appropriately small value of dx (the simulation timestep) to approximate the value of the integral.

Some Integrals (such as the integral of a constant-acceleration motion) can be expressed as a function that you can evaluate once at any time. Most motion in games cannot be easily expressed as a pure function since it has to deal with things like collisions, piece-wise interpolated animations, and user-controlled motion. This is why accumulating motion is more commonly seen, except in the case of things that never interact with anything else (e.g. things that just rotate in place, things that bounce without colliding with anything other than the ground).

3) Rules like the "power rule" are for symbolically integrating a function. Euler / Verlet are numerical methods to approximate the integral, similar to the Runge-Kutta method you may have learned in Calculus class.

\$\endgroup\$
3
  • \$\begingroup\$ Couple followup questions if you don't mind: 1. How did you derive that formula? I don't see anything with modulus in the kinematic equations... 2. So "numeric integration" requires accumulation, and "symbolic integration" does not? \$\endgroup\$
    – davidkomer
    Commented Jun 14, 2018 at 9:26
  • 1
    \$\begingroup\$ 1. I made it up to fit the shape I wanted See Wolfram Example, since the actual force function has a sharp spike like a Dirac delta function, and I didn't want to figure out how to symbolically integrate that. 2) yes. There are several reasons why you'd want to do it numerically rather than symbolically \$\endgroup\$
    – Jimmy
    Commented Jun 14, 2018 at 18:45
  • \$\begingroup\$ FYI I ended up doing it a bit differently, live demo and source at github.com/dakom/ball-bounce-frp \$\endgroup\$
    – davidkomer
    Commented Jun 19, 2018 at 14:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .