Advertisement

discretization of Euler equations...

Started by October 05, 2002 02:42 AM
4 comments, last by maun 22 years, 4 months ago
Hi there, I guess i''m facing a quite common issue; but I still haven''t find a way to deal with it nicely: I''m wondering how to adapt the dt (timestep) to the actual (variable) framerate. I first set dt=difference between 2 frames but it did wrong, especially when the framerate was ''jumping''. So I''m planing to have a fixed dt but trunc the move of the objects to a fraction of what the physical modelisation gets. Any thoughts on usual ways to deal with theses kinds of issues ? BTW, I''ve thinked a while about physical systems and I''ve come to the conclusion that movements are not predictible nor reproductible (bcs of time discretisation that relies on lots of extern parameters...). How do the ''real'' productions deal with it ? (for instance, when a game can "replay" a scene when the hero dies, how can you guarantee the character will re-die?!!!) tanx in advance
Possibly consider having keyframes at every event which seems important. E.g. player being hit, player entering new area etc. That way, it can get slightly out of sync between these, but it is always aiming for an absolute world state which is correct. Whether or not this fits with your current design is another question, but I know that there was an article at Gamasutra on this... Instant Replay (printable version). It is a while since I read it though

Trying is the first step towards failure.
Trying is the first step towards failure.
Advertisement
I didn''t quite understand what you meant with Euler equations. Leonhard Euler invented a lot of things in his life. You could be talking about Euler''s method for solving differential equations or Euler''s equations governing fluid motion, for example. But the physical time step is inversely proportional to the framerate, quite naturally. Eg. if you''re updating the screen 5 times per second the time step should be 0.2 per frame.

- Mikko Kauppila
I wrote ''Euler equations'' because I''ve seen article refering to fundamental dynamic princip as ''Euler Equations''. I''m french so translating these ideas is not easy. What I meant was ''sigma(forces)=m*acceleration'' and Euler applied to fluids is no more than that so I thought this equation was generally named like that in the USA...
hope you got me right!
quote:
Hi there, I guess i'm facing a quite common issue; but I still haven't find a way to deal with it nicely:
I'm wondering how to adapt the dt (timestep) to the actual (variable) framerate. I first set dt=difference between 2 frames but it did wrong, especially when the framerate was 'jumping'. So I'm planing to have a fixed dt but trunc the move of the objects to a fraction of what the physical modelisation gets.
Any thoughts on usual ways to deal with theses kinds of issues ?

Since framerate does vary, you can't base any of your calculations on it. If you do your calculations each frame, then you should dynamical calculate the difference in time between the last frame and the current frame. If your calculations are done every X seconds, then every frame, check to see if X seconds have passed from the last calculation. If so, perform the calculations, reset the variable, and proceed. In all of these methods, frames don't play any role in the physics.

quote:
BTW, I've thinked a while about physical systems and I've come to the conclusion that movements are not predictible nor reproductible (bcs of time discretisation that relies on lots of extern parameters...). How do the 'real' productions deal with it ? (for instance, when a game can "replay" a scene when the hero dies, how can you guarantee the character will re-die?!!!)

If there is no randomness in your system (i.e lack of entropy completely), then with the same starting conditions, you will get the same results. If these results are based on time, then with the same starting conditions, you will get a fixed state for the system at any given time. Thus, if there are no random factors determining, say, the AI of monsters or anything, and you give the same starting conditions, then the scene will play out the same way, over and over again.

Of course, it's nearly impossible to create a completely non-random system. In terms of games (you know gr loves the references to games ), you want randomness. So, to respond to your example, the scene and its states would have to be recorded the first time so that when it is replayed, we get the simulation of non-randomness for the replay.

[edited by - Zipster on October 5, 2002 9:31:32 PM]
quote:
Original post by maun
I wrote ''Euler equations'' because I''ve seen article refering to fundamental dynamic princip as ''Euler Equations''. I''m french so translating these ideas is not easy. What I meant was ''sigma(forces)=m*acceleration'' and Euler applied to fluids is no more than that so I thought this equation was generally named like that in the USA...
hope you got me right!



The "Euler Equations" typically refer to one of two things:

1) The equations governing inviscid, non-chemically-reacting fluid flow. (they can be considered a subset of the Navier-Stokes equations, which support viscous flows)

2) Part of the Newton-Euler equations of motion used for rigid-body and nonrigid-body dynamics, such as determining the flight path of an airplane under various loading conditions. I think the Euler side of those equations refers to the equations of rotational motion, while the Newton side refers to things like the F = m*a that you mention (which is actually Newton''s 2nd Law of Motion)

Most of the time, in these forums, we refer to "Euler integration" also called "simple Euler" or "explicit Euler" integration. This is a technique for numerically solving a wide variety of ordinary and partial differential equations, not just those equations named for Euler.

From your initial post, I see that with your use of dt and numerical integration you are indeed talking about "Euler integration" and not "Euler''s equation."

You are not the first to realize that tying your timestep to the actual frame rate leads to problems! This has been discussed quite a bit on these forums, and others. There is a game design pattern (a software pattern) for time steps that was published in Game Developer Magazine a year or so ago, and you should be able to find that article on www.gamasutra.com. Also, you can search the forum archives here. For now, you will have to use google.com to search the archives. There is a way using google to specify the web site where the search should be done.

FYI, in addition to the "simple/explicit Euler" integration there is also "implicit Euler" to confuse things even more.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net

This topic is closed to new replies.

Advertisement