?

Log in

No account? Create an account
Haven't done enough second-order differential equations or classical… - Blather, Rinse, Repeat
February 25th, 2006
11:08 pm

[Link]

Previous Entry Share Next Entry
Haven't done enough second-order differential equations or classical mechanics recently?

Dad just emailed me to ask about a numerical integration technique that I had mentioned to him some 5 years ago. I'm cleaning up his notation, which does him a disservice - once the notation's clean, the problem's a lot simpler:

Equation 1 (stated without proof in the paper I showed Dad):
s(2) = 2*s(1) - s(0) + a * (delta(t))^2

Equation 2 (Dad's recollection of his high school calculus notes):
s(t) = 1/2 a * (delta(t))^2

Dad's Question:
The 2*s(1) - s(0) accounts for the velocity between steps, but where did the 1/2 go?


Hint:
Equation 2 is wrong, it really ought to be
s(t) = 1/2 a t^2 + v(0) t + s(0)


So. Where did that 1/2 go?

(6 comments | Leave a comment)

Comments
 
From:traypup
Date:February 26th, 2006 06:56 pm (UTC)
(Link)
showoff.
[User Picture]
From:tsmaster
Date:February 26th, 2006 09:12 pm (UTC)
(Link)
maybe a little.
[User Picture]
From:weatherguy2000
Date:February 26th, 2006 10:20 pm (UTC)
(Link)
The 2*s(1) - s(0) accounts for the velocity between steps, but where did the 1/2 go?

The first equation isn't familiar to me. It tells me that the object's position at time 2 is equal to twice its position at time one, minus its position at the start plus the motion due to acceleration.

Your dad's second equation is correct if you are starting at 0 with a 0 speed (velocity); i.e., s(0) = 0 and v(0) = 0.

it almost looks like the first equation is this equation

s(t) = s(0) + 1/2 a t^2

multiplied by 2

2(t) = 2s(0) + a t^2

but not quite. I'm confused as to the inclusion of s(1) in that equation, though.
[User Picture]
From:tsmaster
Date:February 27th, 2006 05:55 am (UTC)
(Link)
Your dad's second equation is correct if
Almost. The delta(t) is actually the bit that I disagree with most in his equation. In our context (and, having played enough with the notation, Dad doesn't recognize what I'm talking about any more, and I haven't really explained enough to expect it to make sense to anybody else, I guess), delta(t) would be t(2)-t(1), and not t(2)-t(0).


The first equation isn't familiar to me. It tells me that the object's position at time 2 is equal to twice its position at time one, minus its position at the start plus the motion due to acceleration.

Yep, it's a rearrangement of the more familiar equations of motion. By stating s(2) in terms of s(1) and s(0) (or really, s(t) in terms of s(t-1) and s(t-2)), you free yourself from a dependence on velocity. This is useful for numerical integration and simulation, because the acceleration terms can remain relatively constant and the position terms can be constrained to behave how you want. If your simulation is also responsible for maintaining high-fidelity velocity quantities, it's difficult to keep all three values (er, all three aspects of the one value) synchronized in a dynamic, unpredictable simulation.


This numerical integration approach is something I know as "Verlet Integration", and I understand that it's frequently used in molecular dynamics, though I learned about it in a talk about how to make "lifelike death animations" (sigh) for computer games. It's useful beyond rag dolls and marionettes, but the basic idea is to model an object you're interested in (e.g. a dead body) as a system of constrained particles. As the simulation (game) proceeds, the particles will be constrained in a variety of ways (non-penetration of walls and floors, staying a specified distance from other particles - the hip bone should stay connected to the knee bone). This environment can lead to a large number of constraints on any given particle, and finding a simultaneous solution to all constraints requires a lot more math than I care to do, especially 60 times a second.

The surprising cheat is that you can satisfy the constraints one at a time, iteratively, over the whole body, and get good results. Let's suppose you've got a marionette whose foot is about to strike the ground at time t(1). So far, so good. At time t(2), the foot will have penetrated the ground unless we do something about it. But the knee has its own momentum, and its motion will influence the motion of the foot, too.

So first clamp the foot to be resting on the ground. But this may come at the price of shortening the distance between the foot and the knee. So we move the foot and the knee apart by a little bit, along the line between them. This moves the knee up and away from the foot, and the foot down and away from the knee. Ooops, down means we're back penetrating the ground. So move the foot back up to rest on the ground, and then move the knee and the foot away from eachother a little bit, and go on for a while - you converge on realistic behavior very quickly, even if it's not numerically accurate.

The guy who introduced me to this technique used it to model the dead bodies of gang members that fall onto awnings and get dragged over curbs in ways that would make Jackie Chan and Bernie (of Weekend at Bernie's) proud. I think it's as impressive that it also allows one to model potted plants and hanging tapestries (just the thing for my Hamlet adventure game - you only think that I'm joking).
[User Picture]
From:tsmaster
Date:February 27th, 2006 06:00 am (UTC)
(Link)
The original paper is here:

http://www.teknikus.dk/tj/gdc2001.htm
[User Picture]
From:stellthebell
Date:February 26th, 2006 10:31 pm (UTC)
(Link)
asjdfajfasjfhjlkdhfasfhj.

This is why you hire grad assistants, silly.
My Website Powered by LiveJournal.com