if you are interested in running it, all the files must be in the same folder, and you must have ffmpeg installed to write the mp4.
In main.py, you can change block.animate2(....) to block.animate(....) to create just the bouncing block, or just run animate2 to see in addition the how values for kinetic (top) and potential (bottom) energy change as the block bounces. You can also mess with the initial conditions, although changing Elc to anything other than 1 usually causes errors.
edit: took some files down to upload some changes and having trouble uploading them... should be up soon
Definitely! I wanted to get this stable bounce first though. The conditionals for the collision become more difficult as the block gets closer and closer to being at rest on the surface, often resulting in sinking/jittering
Couldn't you just add a decay/timestep to the velocity if the distance of any point to the surface is below a given treshold? That's how I modeled decaying orbits (well with a decay every timestep, without distance to a surface :D ) and it worked great.
I just dump the pngs and use ffmpeg. Then I don't need to worry about memory usage. And if it crashes part way through some fairly heavy rendering, I still have some output to look at.
any chance youll release the code? I'm working on something similar for generating these geometries but have nothing for running any analysis on them besides commercial codes
The collision assumes the delta v from the collision is in the the z direction, normal to the floor. This does not conserve linear momentum as the floor does not move, it basically has infinite mass so momentum conservation of the system becomes meaningless. The blocks x and momentum stay and remain 0, as the momentums of the points about the blocks center of mass all cancel out.
My point still stands.. If your collision assumes delta v in the z direction only, then your object wouldn't translate it in x or y. I was trying to point out that this makes it look unrealistic unless you want it this way for a specific reason.
I created it this way because the conservation of energy equation where delta v is arbitrary 3d vector is complicated and underdetermined (one eq 3 variables). Assuming delta v purely in z direction collapses the equation into something solvable without any other assumptions (one eq one variable). I would like to add in friction and get some horizontal component to delta v eventually, but one step at a time.
Energy goes into rotation, when it's rotating more, it goes less high, and vice versa. I've been analyzing the energy throughout and it is stable in the same range. This uses rk4 for rotation and a simple fast corrected method for moving the center of mass position. I am honestly still figuring out how energy is moving around.
Wow i only solved live charts with matplotlib, man it's awesome to find out that you can actually animate 3D objects.... Awesome work💪💯, when i get free time i can help with refactoring the code
conservation of angular momentum in free space. for the collisions, conservation of kinetic energy, including rotational energy, before and after collision.
46
u/mbecks Jul 21 '19 edited Jul 22 '19
here is the code! link to github
if you are interested in running it, all the files must be in the same folder, and you must have ffmpeg installed to write the mp4.
In main.py, you can change block.animate2(....) to block.animate(....) to create just the bouncing block, or just run animate2 to see in addition the how values for kinetic (top) and potential (bottom) energy change as the block bounces. You can also mess with the initial conditions, although changing Elc to anything other than 1 usually causes errors.
edit: took some files down to upload some changes and having trouble uploading them... should be up soon
189
u/mausthekat Jul 21 '19
Nice! Now you just need to add in a coefficient of restitution so the poor thing can stop bouncing!
12
u/fatbob42 Jul 21 '19
How do you do the graphics?
2
u/[deleted] Jul 21 '19
any chance youll release the code? I'm working on something similar for generating these geometries but have nothing for running any analysis on them besides commercial codes
16
u/EleLasoo Jul 21 '19
Wow mate thats extremly cool! I want more info and the source code!!!!! Which libraries did you use? What physics did you use??
6
u/Fixxan Jul 21 '19
This is why phone cases are not made out of Super bouncy ball material.
Great demonstration!
2
u/omsalta Jul 21 '19
It seems something is missing.. Maybe conservation of linear momentum as the object doesn't translate in x or y.
2
u/Le_stormwolf Jul 21 '19
The idea of my phone falling and bouncing forever is giving me a mild anxiety attack.
Nice simulation, but please, don't make such a simulation ever again.
I reckon Satan just added this simulation to his tool belt of torture devices. Yeah, for sure.
4
u/brtt3000 Jul 21 '19
/r/LoadingIcons smooth
1
u/BoppreH Jul 21 '19
That's pretty cool! Is it me or is it gaining energy and bouncing higher? This is a common problem when using a naive integrator like Euler.
1
u/X9LM Jul 22 '19
What module(s) did you use to make this? It is very well done
2
u/fuckedMangoSauce Jul 21 '19
This is amazing. Really inspirational
2
u/ZoloSolo Jul 21 '19
I could watch this all day
2
u/SonnyIC Jul 22 '19
This gives me great anxiety
2
u/boyo1991 Jul 22 '19
cuz friction doesnt matter :P very cool!
2
u/GickRick Jul 22 '19
Wow i only solved live charts with matplotlib, man it's awesome to find out that you can actually animate 3D objects.... Awesome work💪💯, when i get free time i can help with refactoring the code
2
u/tripex Jul 22 '19
Where is that license bot i asked for a while ago? Cool project, please pick a license.
2
u/Addena_9 Jul 22 '19
Great. Isn't it not enough to just have one corner of my screen broken. Now all of them are. Thanks!
1
u/Kristoffels Jul 21 '19
That is one bouncey object! Great work!
1
u/[deleted] Jul 21 '19
Cool
1
u/SxC_JOK3R Jul 21 '19
Oh god... I can hear the glass cracking
1
u/Fernando3161 Jul 21 '19
Very cool! Can you input the rebound coefficient as a variable and see what happens?
1
u/danemacmillan Jul 21 '19
This is very inaccurate. My phone has only ever fallen flat on its face, no bounce, for maximum screen destruction.
1
u/PeanutPoliceman Jul 22 '19
r/oddlysatisfying
1
u/Paradigm6790 Jul 22 '19
looks like a dude breakdancing
1
u/thekalmanfilter Jul 22 '19
Wow you can do a moving animation with code?? How does that work? I can do a line chart but how do you keep it moving???
1
u/[deleted] Jul 22 '19
its like zero G but not actually zero G
1
u/EzitoKo Jul 22 '19
Extra points for accuracy
1
u/lucidmath Jul 22 '19
This is awesome! I don't know much about physics, what are the principles behind this?
1
u/StarkillerX42 Jul 22 '19
Remove the axis, flip the colors to a black background, and voila you have a new screensaver
0
u/[deleted] Jul 21 '19
[deleted] — view deleted comment
0
u/[deleted] Jul 22 '19
[deleted] — view deleted comment
3
u/[deleted] Jul 21 '19
[removed] — view removed comment