Building a Physics Engine with C++ and Simulating Machines

680,526
0
Published 2022-01-31
I talk about the basics of physics engine design and the theory behind rigid body constraint solvers. Here are all the resources you'll need to build a physics engine that is similar to the one I show in the video:

Source code of my physics engine:
github.com/ange-yaghi/simple-2d-constraint-solver

Euler method for solving differential equations:
en.wikipedia.org/wiki/Euler_method

Runge-Kutta method for solving differential equations:
en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods#…

Physically Based Modeling: Principles and Practice
www.cs.cmu.edu/~baraff/sigcourse/notesf.pdf

Source code of my real-time video encoder:
github.com/ange-yaghi/direct-to-video

Source code of my game engine:
github.com/ange-yaghi/delta-studio

#physics #simulation #programming

Check out my GitHub profile!
github.com/ange-yaghi

Join my Discord!
discord.gg/R2baT4t5U7

Follow me on Instagram!
www.instagram.com/ange.the.great/

If you like my work and would like to support me, consider donating!
ko-fi.com/angethegreat

Thanks for watching!

All Comments (21)
  • @theDemong0d
    No sleeping here, there is a huge lack of technical content on youtube at this level, these videos are killer. Keep it up. Would love to see the deep-dive on your fluid sims for your engine project.
  • @itskittyme
    "i wrote this advanced physics simulator" "oh and then i ran into some problems with making the video" "thus i quickly built my own screen capturing software which works better than this giant open source program that's been around since 2012" okay
  • @AngeTheGreat
    Useful or pointless video? You tell me :D Thanks for watching 💪
  • @lukewellcash
    Your videos should seriously get more attention then they do. Awesome work!
  • A note on implementation: your RK solver is very tightly coupled with the design of the system you're integrating. Usually it's best to try to decouple the integrator from the system itself and implement it more generically. For ordinary ODE's you just need a function that calculates a vector of derivatives from a vector of coordinates, and that's all your integrator needs. And your physics engine can index into those arrays to access coordinates of any given rigid body.
  • I've studied physics for 2 years and computer science for another 3 years. I'm already thought of doing something like that, but it's very impressive to see how well you've done it. There are so many layers of complexity to what you're showing
  • @Cathal7707
    This is incredible. Constraint solving is stuff you do early on in an engineering degree but I never cared for it because I was always into the more computational stuff. Seeing you come at this from the computational side first has given me a whole new perspective.
  • @jojodi
    Awesome stuff! Highly recommend you look into iterative techniques (Gauss-Seidel, or more complex Conjugate Gradient). They are probably in fact easier to implement than the Gaussian Elimination, and you can terminate iterative approaches when the error is low enough. Convergence rates are almost always related to conditioning of the system being solved, which will depend on what combination of constraints you have in your simulation. Note that isn't worse than the elimination case: poor conditioning also causes numerical instability in that algorithm as well.
  • @opti12
    All this goes far over my head but it's so impressive to see someone make things like this and to share it online, even creating a screenrecorder in the meantime. Crazy!
  • @scremeo8522
    As I'm currently preparing for an upcoming exam in numerical analysis, I find it interesting to see this really cool application of most of the methods I've learned! I'd like to write my own physics-engine right now, if I didn't have to study at the moment 😅
  • @Ahsan_Fazal
    You're my new favorite YouTube content creator. WOW! This level of knowledge and expertise is something I rarely see on YouTube. KEEP UP THE GOOD WORK!!! <3
  • @grevel1376
    You got a new subscriber. I arrived to your channel by a reddit post with a link to your engine simulation video, and I guess now I'm binge watching all your videos. Amazing work man.
  • @IONYVDFC
    Interesting to see someone reviving the (at least my) experience of writing a physics engine. It was really a brain crushing journey for me to do this in the 90' with less accuracy, much less computing power, my very immature knowledge of math, let alone internet resources on this topic. But I have strong memories indeed from my eureka moment after real-time simulating a cloth, and a few weeks later seeing the same idea rendered on a Silicon Graphics cluster on a computer fair in Brussels.
  • @basile5490
    Just discovered your channel, and i see a lot of advanced, neat projects that really sparks my interest. This physics engine is very cool ! Im impressed to see that you make all that in C++, it genuinely makes me want to make similar stuff on a low level. That's really inspiring (even the nerdy mathematical details ! Along with the sources in the descriptions, those are the crunchy bit for me). Keeps up the awesome work !
  • @willi00willi
    I just got recommended this video today, and I am blown away! Can't wait to explore more of your channel's content
  • I really enjoy watching your videos and trying to understand everything. I find that there is something satisfying in the way you explain things. Keep up the amazing work!
  • @actuallydaneel
    every vid you make is just such a joy to watch, from the content to the editing it's just sublime. sincerely, good job.
  • @Skeffles
    These simulations look awesome! Can't wait to hear about the project you're making this for.
  • @jroseme
    Super interesting and nice visuals to boot. It’s a relief to see an actual software application of this linear algebra stuff I’m learning.