I've been reading some in the Baraff papers on differential equations.
First, when he's talking about Euler integration and it being derived
from the infinite Taylor series, I noticed that as we're calculating
forces & torques, we're actually calculating the 2nd derivative.
So, instead of the often-seen Euler integration:
F=calcForces();
acc=F/m;
vel+=acc*dt;
pos+=vel*dt;
(and get an O(h^2) error term)
You would instead use one more term of the Taylor series:
F=calcForces();
acc=F/m;
vel+=acc*dt;
pos+=vel*dt+(dt^2)*acc
(compare the last line with Y_new=h*f(Y0)+h^2*f'(Y0)+O(h^3))
I always thought if I did a thing like that, I'd have to just use
dt*acc or 1/2*dt*acc, something like that. I'll try the new approach,
since that seems to get you from error O(h^2) to O(h^3) without any
cost. Haven't read about that anywhere.
Also, another chapter of Baraff's papers explains implicit
differential solving, and talks about solving a differential equation
backwards in time. So instead of taking some steps into the future, it
tries to be in the future and find a value which goes back to the
value you're currently at:
Y_new=Y0+h*f(Y_new)
Where Y_new is the value in the future, and Y0 is the current value.
To estimate Y_new, he finally comes up with:
delta(Y) = f(Y0) / (1/h*I - f'(Y0))
Where delta(Y) is ofcourse the change in value, f(Y0) is your normal
function which you already use, I is an identity matrix, h is the
timestep, and f' is ofcourse the 2nd derivative.
However, as I stated at the top, it seems with the forces -> position
pipeline we're already calculating the 2nd derivative (the
acceleration), which is a problem for most other differential
equations, it seems. So in my not too mathy vision, that would mean
that instead of calculating f'(Y0) and coming up with a matrix, as is
done in the Baraff paper using explicit formulae, it is possible to
state that the 'acc' variable IS f'(Y0), and you get:
delta(Y) = f(Y0) / (1/h - f'(Y0))
<=>
delta(Y) = vel / (1/h - acc)
Not that I find this formula intuitive in its meaning.
In the Baraff paper, this is used for solving a stiff ODE, with the
example being a stiff spring (F=-k*y). We all know the situation when
applying a lot of braking torque and the first time the wheel starts
jittering around velocity 0. This time reversal approach supposedly
solves this problem and comes back with the neutral point (y=0) with
whatever step you take. Seems like something to investigate further.
:)
Does anybody have experience with this approach, and can anyone see
where my thinking may go wrong, as I don't really think the last
formula seems to intuitive.
Thanks for any thoughts,
Ruud van Gaal
Free car sim : http://www.racesimcentral.net/
Pencil art : http://www.racesimcentral.net/