Live data from Hacker News

Ten Minute Physics

matthias-research.github.io

31–40 of 43 posts

Re: Ten Minute Physics

#31

This honestly reminds me of Feynman Lectures. It's similar to that except Ten Minute Physics explains slightly more modern physics concepts.

Classical and continuum mechanics are hundreds of years old. A surprising amount of the numerics is pretty old too.

Re: Ten Minute Physics

#33
I have a question about the position-based dynamics approach. Since the constraints are solved iteratively for every element in the simulation, you can still end up with a system where the constraints do not hold for some of the elements.

Example: you have a link between A and B, and a link between B and C. If you adjust A and B according to the length of the link, and then B and C according to the other length, you've moved B again, and the firsts link might not have the right length anymore.

Re: Ten Minute Physics

#34
post #2

There are some great content on his YouTube channel as well.I highly recommend to have look. He is one of the people behind PBD and XPBD. I found that watching his videos and playing with his demos really helpful while studying the paper.

This is the channel with more content:

https://www.youtube.com/@matthimf/videos

Re: Ten Minute Physics

#35
post #33

I have a question about the position-based dynamics approach. Since the constraints are solved iteratively for every element in the simulation, you can still end up with a system where the constraints do not hold for some of the elements. Example: you have a link between A and B, and a link between B and C. If you adjust A and B according to the length of the link, and then B and C according to the other length, you'…

Depends on how you solve the constraints. The papers use an iterative method that might not converge to meet all constraints all the time but you can use others instead. In general though the constraint satisfaction is good enough with the iterative approach.

I’m writing a physics engine in my spare time for fun using XPBD so here’s a look at the iterative method in action: https://youtu.be/A3_W_EFFsm8

This is running in Chrome at 60Hz with fifteen sub-steps, each with one constraint solver iteration.

Am currently integrating rigid bodies which is fun.

Re: Ten Minute Physics

#37
post #15

Earlier quoted context omitted.

The problem sounds like you're doing O(N^2) calculations at every tick because each particle has to interact with every other particle. To make it faster you should keep some spatial datastructure so that you can query the other particles within a certain range of your current particle and just interact with those, ignoring the rest. The usual implementation is an octree or something similar. That said, N=100 should…

I do have a parameter so that each particle only takes into consideration other particles within 750 units, when the free space is 3000x3000x3000 units, but this parameter did not seem too critical, and it's still calculating the distance between each pair twice technically, so I guess I could speed that up. Vector/"table?" operations seemed slower than plain loops, not sure if there's plain interpreter speedup possi…

These references helped me a lot when building a spatial hashed fluid sim that runs on the GPU:

https://developer.download.nvidia.com/presentations/2008/GDC... https://wickedengine.net/2018/05/21/scalabe-gpu-fluid-simula...

(See from page 16 on the NVIDIA presentation)

Re: Ten Minute Physics

#38
post #33

I have a question about the position-based dynamics approach. Since the constraints are solved iteratively for every element in the simulation, you can still end up with a system where the constraints do not hold for some of the elements. Example: you have a link between A and B, and a link between B and C. If you adjust A and B according to the length of the link, and then B and C according to the other length, you'…

Depends on how you solve the constraints. The papers use an iterative method that might not converge to meet all constraints all the time but you can use others instead. In general though the constraint satisfaction is good enough with the iterative approach. I’m writing a physics engine in my spare time for fun using XPBD so here’s a look at the iterative method in action: https://youtu.be/A3_W_EFFsm8 This is runnin…

I think the constraints have not one solution. E.g. multiple overlapping polygons in 2D, how would you resolve that globally in a way such that the solution converges to the physical solution?

Re: Ten Minute Physics

#39
post #33

I have a question about the position-based dynamics approach. Since the constraints are solved iteratively for every element in the simulation, you can still end up with a system where the constraints do not hold for some of the elements. Example: you have a link between A and B, and a link between B and C. If you adjust A and B according to the length of the link, and then B and C according to the other length, you'…

I think your question speaks to something deep and interesting about XPBD.

All classical mechanics sims revolve on some level around "integrating" Newton's second law of motion: F=ma. Force equals mass times acceleration. XPBD constraints correspond directly to forces, and acceleration is the second time derivate of position. So to update positions every frame, which is what we want our physics sim to do, we need to integrate F=ma.

Usually we want to use an integrator in the family of "unconditionally stable" integrators. These integrators are guaranteed not to blow up, no matter what weird, difficult input the user gives to the simulation. In realtime physics sims we generally use one called "Implicit Euler." And Implicit Euler is the worst one! It's the least accurate and it adds huge amounts of artificial damping, but it has one really big thing going for it. It's the most resilient to "under-converged" solutions to the equations of motion.

So, like you pointed out in your question, if you resolve the constraints one after the other, constraints further down the list are likely to violate previous constraints. Most of the time you can mitigate this by running over the list of constraints multiple times, but you'd have to do that many many times for your constraints to perfectly "converge," such that they are all simultaneously satisfied.

The more accurate and energy preserving unconditionally stable integrators, like "Implicit Midpoint," require perfectly converged solutions. If you don't resolve your constraints perfectly, the "unconditionally stable" Implicit Midpoint will explode! But good ol' Implicit Euler is much less up tight. You can give it surprisingly under-converged solutions and it'll keep on trucking. The shortcomings of Implicit Euler are reduced by taking smaller timesteps between frames, so you generally get the best bang for your buck by investing compute time into more frames with a sloppy, non-converging solver, than using a better integrator that forces convergence.

At least that's what it looks like now. There's still tons of active research going on in these areas. Maybe someone will discover a faster solver that makes convergence easier, in which case we'll all switch over to move sophisticated integrators.

Post reply on HN