I initially thought I would just use the equation of motion for an object falling using initial position, velocity, acceleration. However I soon realized that at each impact I needed to reset the time and reverse the velocity direction. I also included a coefficient of restitution which is effectively a single linear value that dampens the energy of system at an impact. The simple code showing time dependent height is below.
Python basic bouncing code.This tutorial is something I had wanted to follow in the past, now it's my homework - sweet.
I got animation working, sorta. I do the calculation. Then I animate by rebuilding the array by stepping through and replacing a zeros array with the correct elements. the only thing is this leaves trailing zeros in the array. I would like the remaining array to be non-existant, such that there is no trailing line at the end. Perhaps I need to have the figure drawn, but rebuild the array each time with incrementing size. Python Code
note: animation below does not show in firefox due to lack of support for mp4.
I found a tutorial (can't find it anymore) that showed how to take an image file apply it to a pygame surface and move it across the screen. Unfortunately, I was a bit confused by how to make it run without moving my mouse across the screen.Until, I found that the event check for loops were a little funky after looking at the PyODE sample files. A note on PyODE is now apparently obsolete. The sourceforge site says they are not included in the OpenDynamics Engine. This will be another topic down the road. PyGame basketball bounce demo. Don't forget the nifty graphic too.
Programming was not so much of the difficulty as figuring out how to save a video of the animation. It turns out the only way I could find was to use the function ofSaveFrame() which saves a .png. This ended up causing serious problems for me because I was using my frames per second to calculate the velocity of the ball. When saving the frames to disk there was significant variation between frame timing and this variation causes the ball velocity to vary significantly and hence to bounce all over the place. openframework.mp4
This was almost entirely copied from this html5 tutorial. I made some small modifications to remove the restoring forces and include a gravity-like force. I've included this mostly as a starting point to understand working with javascript. It is neat how much can be done in browser at this point. Here is the html5/canvas code.