It's free to join Gamasutra!|Have a question? Want to know who runs this site? Here you go.|Targeting the game development market with your product or service? Get info on advertising here.||For altering your contact information or changing email subscription preferences.
Registered members can log in here.Back to the home page.

Search articles, jobs, buyers guide, and more.

Gamasutra
June 18 2008

An Easy Way Of Solving Complex Mathematical Models: The Finite Difference Scheme

arrowrightPage 1
arrowrightPage 2
arrowrightPage 3


Printer Friendly Version



Sign up for the Gamasutra Daily Newsletter!

Telltale Games : Technical Artist [11.22.08]
Namco Networks America Inc. : Flash Games Engineer [11.21.08]
War Drum Studios, LLC : Network Game Programmer [11.21.08]
First Act Interactive : Project Lead Software Engineer [11.21.08]
Sony Computer Entertainment America : Senior Manager of Game System Engineering [11.21.08]
Cryptic Studios, Inc. : Lead Game Master Support Representative [11.21.08]
Sparkplay Media : QA Manager [11.21.08]
Cryptic Studios, Inc. : User Interface Designer [11.21.08]
Treyarch / Activision : Technical Director [11.21.08]
Ignition Entertainment : Motion Director [11.21.08]
Ignition Entertainment : Producer [11.21.08]
Sony Pictures Entertainment : Software Engineer / Lua Scripter [11.20.08]
Sony Computer Entertainment America : SR. TECHNICAL PROJECT MANAGER [11.20.08]
Edge of Reality : Project Manager [11.20.08]
Stealth Startup : 3d Graphics Programmer - Virtual Worlds [11.20.08]

View All    Post A Job

Post Resume


Upcoming Events:
DIG London Game Conference
London, Canada
11.27.08

5th Australasian Conference on Interactive Entertainment
Brisbane, Australia
12.03.08

IEEE Symposium on Computational Intelligence and Games
Perth, Australia
12.15.08

2K Bot Prize
Perth, Australia
12.15.08

The 6th Annual Mobile Games Forum 2009
London, United Kingdom
01.21.09

Submit Event

View All


An Easy Way Of Solving Complex Mathematical Models: The Finite Difference Scheme

(Page 1/3)
Next arrow


[In this technical article, veteran coder Jovanovic looks at dynamic game-related effects like heat distribution models, explaining useful mathematical formulas that should help decrease the amount of programming.]

In games today, more and more realistic effects are expected, and the best way to get them is by using the correct physical models. The problem many of these models share is that they are represented with partial differential equations (PDE).

The solving of this type of equation is often avoided by using different types of tricks. It is sad to say, but in the end tricks are just tricks, and they don't give the correct solution - just something that looks like it.

There are two main reasons for using tricks. The first one is that they are usually much faster - but with the increase of CPU power we can give up some of the speed to get more reality. The second reason is that most people think solving PDEs is very complicated, and in many cases this simply isn't true.

In this article we'll show a standard method of solving PDEs and how to implement it. This method is called Finite Difference Scheme (FDS). It is not the most exact and stable method that exists, but is much better than using tricks, and it is the easiest to understand and implement.

A game example of the use of PDE

Let us try to show the advantages of using a mathematical model with PDE and the FDS method in a game. Let's say we wish to have a trampoline, or something like a rubber sheet that represents a wall that moves with the wind. How would it be implemented in a game? The approach in games today is to use a spring system.

Anyone who programmed spring systems knows this isn't the simplest task in the world. We have to create classes for nodes, springs, the hole system; and than calculate the forces from all the springs, and than apply the sum of forces corresponding to each node. And after all that work we get something that can often become numerically unstable.

Spring systems are actually great and very complex objects can be modeled with them, but in this case we don't need them. There is a much easier way.

The behavior of a trampoline, or the vibrating membrane, is one of the standard physical problems and one of the basic PDE. The equation that represents it looks something like this:

When someone sees something like this the natural reaction is "I'll stick with spring systems, since it's surely much easier." This is wrong for a couple reasons.

First, the implementation will be simpler; less programming will be needed. Second, the final result will look better because we used a better mathematical model, or in other words we modeled a trampoline and not just a bunch of nodes connected with springs. Third, there will be less calculation which means the code will work faster.


(Page 1/3)
Next arrow






join | contact us | advertise | write | my profile
news | features | contract work | jobs | resumes | education | product guide | store