🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Not understanding Gauss Seidel to solve this equation

Started by
6 comments, last by NewbZach 4 years, 6 months ago

I'm following a lecture here https://www.youtube.com/watch?v=iwEmcWjrcbA&t=1506s to resolve all violated pairwise constraints in a collision system. He derives at the end the equation:

(e/dt) - (JV) - (dt * J * (1/M) * F) = J * (1/M) * (1/J) * lambda

e epsilon a small floating point value, matrix J is a diagonal matrix holding all the directions of the constraints, M is a diagonal matrix holding all the mass and inertia tensors of the bodies, F is a vector holding all the external forces, and lambda is the magnitude of force to apply F = 1/J * lambda

the equation can be written in parts, b = A * lambda, where b is a vector and A is a matrix, he then says that lambda can be easily solved with Gauss Seidel, but I don't understand how. Can't I multiply b with inverse A to find lambda? I've re-watched the video about 5 times now but he goes through that part at pretty fast. He mentions it at the last 5 minutes of the video. Can anyone help clarify my misunderstandings? Thanks!

Advertisement

While you certainly can multiply by the inverse of A, if your system is sufficiently large this becomes unwieldly (as matrix inversion usually requires time proportional to the matrix's size cubed). This is probably why it is suggested to use an iterative method.

Oh I see, thank you that makes sense! So would using Gauss Seidel be something like:

A11 * lambda1 + A12 * lambda2 + A13 * lambda3... = b1

A21 * lambda1 + A22 * lambda2 + A23 * lambda3... = b2

...

would it be something like this where I then solve for lambda1, lambda2 etc?

Also how would I know when it has converged enough? Because in pseudocode that I have searched for online, it is usually in a "while not converged", how would I handle this boolean check? Thank you so much!

Oh I see, thank you that makes sense! So would using Gauss Seidel be something like:

A11 * lambda1 + A12 * lambda2 + A13 * lambda3... = b1

A21 * lambda1 + A22 * lambda2 + A23 * lambda3... = b2

...

would it be something like this where I then solve for lambda1, lambda2 etc?

Also how would I know when it has converged enough? Because in pseudocode that I have searched for online, it is usually in a "while not converged", how would I handle this boolean check? Thank you so much!

Sorry for replying twice and adding this new comment, I can't edit my original comment for some reason. Would checking for convergence be subbing in the lambda values into equation 1 and checking if it is sufficiently close to b1?

That's one way, but you could also check the change in the lambda vector after each iteration to see if it is within some tolerance.

@RulerOfNothing Ah I see that seems like a better way! Thank you!

This topic is closed to new replies.

Advertisement