Quote:Original post by Anonymous Poster
Quote:Original post by grhodes_at_work
Yes, but "simple pendulum with friction" != "implicit Euler"! The function solves a very specific problem, and isn't a generic solver as the function name implies. This was my point, :).
I agree. The OP did mention the code came from "Game Physics". The section of the book from which it came is specifically for the simple pendulum with friction.
From what I can tell, that book discusses how to set up the implicit Euler method for general forces.
I am curious how you avoid using Newton's method to solve the implicit equation. Any hints on other alternatives?
Your general understanding is correct. To solve an implicit system of equations numerically, you do need one or more derivatives, in order to compute the incremental correction that nudges you toward the answer at each iteration. Newton's method is one approach, but there are many variations that use one or multiple derivatives, different weighting and preconditioning strategies to accelerate and improve the chances of reaching convergence. In general the derivatives may have to be themselves approximated numerically, and this can introduce new equations into the system. (For the sample code, the derivative is computed analytically.)
The book does talk about implicit Euler in a more general fashion. It just happens that the example code (the
quoted example code) is not a general-purpose implementation of the method. It is a problem-specific example. The sample code from "Game Physics" does solve the pendulum problem using the implicit Euler technique. It does illustrate exactly what the author intended to illustrate in his book, very nicely. To do so, it uses built-in knowledge of the specific geometry of the pendulum problem to produce the input at each step.
From the wording of the original post, I gathered that the OP thought a general force could be simply added in and the code would work fine for a more general problem, e.g., a non-pendulum problem. This isn't the case, of course. The method cannot be used, as-is, for general problems. This is in part because it is built specifically around the geometry of a pendulum, exactly as the author intended. The other reason the method isn't too flexible as is (and this is the reason I didn't immediately see what was going on before the OP mentioned where the code came from and I had a chance to see the context of the code in the book) is because it is written in a way that the entire motion time history is computed in one call, for n time steps. There are no provisions to allow the applied forces to change at each time step, and it isn't really intended to be called in sequence multiple times.
[Edited by - grhodes_at_work on November 25, 2005 11:06:42 PM]
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net