"I can probably do it better" every programmer, hell, every person creating something says this and immediately regrets their decision until it's complete
I remember that I was still with only 2 years of experience on Roblox Lua when I saw that time's best vehicle module. I wasted a month or two trying to make a better one just to abandon it and realise that I can do it now, but if I attempt it's not even going to benefit me in any way.
I did physics sim stuff too (and want to do more) and it seems like our brains are of similar smoothness, so I understand your pain. It's comforting to see someone else struggle with the same stuff.
Can only agree! I'm working with an advanced optics sim at the moment and some days I just wish I could close my eyes and forget my existence for a little while... But when it works, then it's all worth it again!
I think you need some damping/friction forces. It looks like the springs in the ball are perfectly elastic right now, so each impact will just increase the internal pressure, causing each triangular section to oscillate more and more (like simple harmonic motion, but complicated since it's in a connected mesh of springs). Dissipating the energy as "heat" should keep the ball's internal pressure more stable and prevent the triangular sections from vibrating faster and faster.
You could probably achieve more stability if you could somehow make the ball leave an imprint of its momentum on any object it comes into contact with, on the understanding that contact between two objects must achieve a null state before contact is broken (like with objects that are artificially forced into place, like walls that hang in the air, returning equivalent negative values). In nature, we are supposed to subtract the influence of the struck object(s) from the original trajectory of the striking object to find its path through space. If we don't, the moving object inherits that extra energy of being struck back by the wall and internalizes it, without losing any of its original velocity, causing the structure to eventually warble out of control the longer it moves. I don't know how it works in code, though.
#1) There seems to be not enough decay to the energy in the springs #2) The Energy is stored in the single springs and not dissipated to the other springs, allowing for resonance. And as those who resonate more will re-collide earlier, there is a positive feedback loop to this resonance.
Hey Gonkee, I came across your video some time ago and it inspired me so much. I loved seeing your entire raw process, struggling and learning an entire language from scratch. It gave me a huge motivation boost and made me realise that it's possible to pull off something as crazy as this through sheer will. Thanks a lot for this. You're a genius.
imagine having to code all the quantum particles and then atoms and physics and complexity of this universe, those beings may as well be gods compared to us
Disclaimer: I know very little about numerical integration. But maybe using a symplectic integrator (e.g. velocity verlet) instead of Runge-Kutta would help with the oscillations you're getting.
@@Gonkee Although RK4 is a big improvement on Euler method, and is good enough most of the time, it still can be improved (usually in the cost of computing effort and complexity of the algorithm). Specifically, at 7:10, as a result of increasing the spring coefficient to 999999, the solution probably now have very high gradients and your time-step is probably not small enough to capture it and the solution completely diverges. In the Numeric Analysis world, we say the problem/equation is "stiff". If you want to somewhat keep the simplicity of the integrator, you might be interested in the adaptive RK45 method. If you are willing to invest in more complex methods, maybe consider researching into implicit RK methods. This is the first time I hear about the Verlet's method proposed above, but maybe it's also a good fit. Disclaimer: I never used implicit RK methods, but I heard from a professor that they are used to solve stiff problem.
@@Gonkee i think the problem is that you're trying to solve a set of partial differential equations by treating each PDE as a separate ODE. im by no means an expert but afaik there are algorithms designed for solving PDEs that are much more stable
Im in my first year in college studying software engineering and I thought chemistry was gonna be useless to me.. but I now saw you using the ideal gas formula and now I’m motivated to study 👍 thanks, and great video!
Thank you Gonkee. You have made all the pain of teaching physics worth it. I am thinking that I can use your video as motivation for my students. Would be great for the computational physics class that I taught a couple years ago. I do feel a bit guilty, that I can't go help fix your code right now. I'm sure you'll figure it out...you are the best type of student. Very proud of you young man.
Bro, ur insane. I love that type of humor so much, the editing is well paced and those random images there and here alongside all the dumb memes, that shit is insane. Keep going on, the content is insane as well man
You got style, patience and brains man. Keep it up. I’m not even in this field but watching you think through the problems really made me smile. You’ll go far.
"How many of the average person's fart gasses are needed to make the pressure in an ico sphere go from 1 atmospheric pressure to 2 atmospheric pressure?"
You have an awesome and interesting way of communicating your ideas and experience. I would love to see some NN, or other machine learning subjects tackled by you.
1. Fix: (Not easy to implement) When solving the harmonic oscillators (these spring mass thingies in the icosphere) with an explicit scheme like RK4, the systems energy increases from numerical errors until it diverges to infinity. When solving with an implicit scheme (much harder to implement), the systems energy converges to zero and is therefore to be preferred. 2. Fix: (Turbo easy to implement) I assume You did not implement a damping term. In reality, a pendulum or an oscillator never oscillates for ever, it loses energy due to friction and shit. If You include a small damping term into the oscillators You will see iz gunna wok. 3. Fix: (Bruh) Just decrease the time step size. The RK4 scheme should do better at 120Hz or 240Hz. He actually implemented a daming term in 6:07 The parameter 'dampingConstant' is probably set too low - much too low
@@madmax43v3r Yep: If the step size is too large on an explicit scheme, everything goes boom. There are situations where a damping term generates a converging solution.
@@TheRainHarvester In this case: The machine error is orders of magnitudes smaller than then error of the integration scheme. => Doubles would probably not make a significant difference. In Your case: The major source of errors was the machine accuracy for small float numbers. Hence, double precision solves the issue.
As a fellow sleep deprived math enthusiast and programmer who also likes to inflict pain upon himself with impossible projects; this video and your channel as a whole is great. Thank you "Inspecto" :)
That was too much work for the amount of subs you have! Such an underrated channel! First video of yours I’ve seen but I’m now subscribed haha. Keep it up
It's truly a joy to see others go through the pain I'm subjecting myself to, okay that sounds cruel, but at least it makes me feel better! You did a great job though, I'm looking forward to seeing more simulation stuff (and I would unironically watch 2h of this)
This is amazing! (I also want to make my own physics engine :)) Also, it's really cool how your new channel is *already* more popular than your old one :O
Friction and dampening, my friend, that is the key to stabilizing. There are multiple different kinds, and often they are small enough to be dismissed. But whether it is air resistance or the springiness being dampened by the rubber converting motion into heat, or whatever, it is usually some variation of a force (/acceleration) in the opposite direction of the velocity, and is some proportion of the velocity or the velocity squared. So it will always attempt to counter the velocity, and bringing the system towards a stop (and gravity in this case keeps adding to the motion of the system). And since the velocity becomes slower and slower, the friction/dampening proportional to the velocity becomes lower and lower, thereby making the slowdown exponentially decreasing (sort of asymptomatic towards stand still).
If you think about it: the soft-body eventually derping out is because of heat, even if heat is technically not implemented. The potential energy gets transferred into velocity of the points, giving the initial illusion of bounciness. The body being a closed system means that entropy must reach an equillibrium. It wont just keep bouncing as this is a state of high entropy, but instead each point will eventually go into it's own direction. This results in things derping out unless you transfer energy out of the ball, for the same reason things derp out if temperature increases too much. This isn't even technically a bug, just not working to simulate large scale objects, which are usually made up of more particles then you could simulate in a lifetime.
6:45 - it's not the accuracy of explicit methods that's bad - it's instability. You raise your dt too high - you get an unstable system. And Runge-Kutta is excplicit too, so you'll inevitably will bump into problems with stability when you crank certain numbers too high or too low. Also, if your spring constant is very high - it's better in terms of calculation to implement them not as springs, but as a rigid rods. Also, you can add some dampening to your system to "vent" some instabilities that accumulate over time. I'm basically trying to accurately simulate problems like that (inflatable shells dynamics) and it's a living hell (But i'm going to use FEA since I don't need any real-time simulation).
@@johnsherfey3675 it's not just rounding. But he could use double floats. Sometimes it's the approach and departure i describe in my micro gravity simulation.
lol, I made an entire soft body engine too! xD. I just made some springs applied some forces and tweaked it until it looked kinda decent. If someone wants I can publish an unlisted video with my bouncy engine. You got some real balls by the way going into that project with like no experience with the language or the only a little bit with the renderer, on such a giant project. Maybe I should do that more, just go into the hardest project I can think of. Anyway, I love the jokes in the video! The vid was a feast.
I hate to be the 70th comment but how are your first few videos so good? Also i love the low bitrate tobu candyland lmao Oh, and a dani reference too, this channel is going places
I once made a cloth simulator (spring-mass system) and it had similar instability with ramping oscillation. It became a lot more stable when I introduced some sort of fake friction (just multiplied the velocity of each point by 0.99 every time step).
Nice one bro. That's an awesome project. During lockdown, I decided to make a program that tries to predict which stocks are going up and down. Programmers be crazy...
Dude what you did is amazing. Especially knowing what you know in the amount of time you did it in. This is really impressive! The most I can do is draw a square. Actually, I can't even do that anymore because I forgot all my high school Java. Keep it up! You will be big brain one day! (youre already big brain tho
One downside to the ico sphere, you don't get fine control over the resolution of it, if you want to increase the number of vertices, you have to subdivide it. Whereas UV and square spheres can have X by Y number of vertices, which is better for things like spherical terrain.
awesome video!!! Maybe to fix the ball you can add some sort of communication between adjacent points so that the small oscilations dont get out of hand?
You might want to use implicit methods. The common technique in Physics-Based animations is Backward Euler. This would be much more stable. If you really want to keep using explicit methods, make sure your time step is low enough and maybe add some damping. David Levin from UoT has uploaded superb videos for course on his youtube account. You should be able to learn everything you need to implement the other parts of your engine. PBD might have been a nice alternative way to make everything fit seamlessly in the same simulator, but I have personally made it work with FEM.
I was laughing so much as the ball bounced down because I was just expecting it to explode and just the anticipation was unbearable. You're amazing dude. I know you said you think these videos are too much effort and too little reward but looking at your channel these seem to be the ones people want. Keep it up. I used to think I was a good programmer then I saw all the maths, googled Runge-Kutta 4 and I died.