Game Development Reference

In-Depth Information

Runge-Kutta methods having a greater number of stages are derived in a

manner similar to that used to derive the two-stage method, except that higher-

order Taylor series expansions are equated. Without concerning ourselves with

the details of the long and uninteresting derivation, we state a popular four-stage

Runge-Kutta method, often called the
RK4 method
, as follows.

h

[

]

y

=+

y

Kxy

(

,

)

+

2

Kxy

(

,

)

+

2

Kxy

(

,

)

+

Kxy

(

,

)

(16.80)

i

+

1

i

1

i

i

2

i

i

3

i

i

4

i

i

6

(

)

(

)

xy

,

=

fxy

h

,

K

1

i

i

i

i

h

(

)

(

)

K

xy

,

=

f x

+

,

y

+

K xy

,

2

i

i

i

i

1

i

i

2

2

(16.81)

h

h

K

(

xy

,

)

=

f x

+

,

y

+

K xy

(

,

)

3

i

i

i

i

2

i

i

2

2

(

)

(

(

)

)

K

xy

,

=

fx hy hK xy

+

,

+

,

4

i

i

i

i

3

i

i

The RK4 method is usually more than adequate for the types of real-time simula-

tions encountered in a 3D game application. The calculation of Equation (16.80)

is very straightforward and also rather efficient for the accuracy that the RK4

method provides.

16.4.4 Higher-Order Differential Equations

We mentioned earlier that a higher-order differential equation could be trans-

formed into a system of first-order differential equations, allowing us to solve it

numerically using the methods already presented. First, let us consider a second-

order differential equation

′′

()

(

′

)

y

xf

=

xyy

,,

.

(16.82)

This can be expressed as the following pair of first-order equations.

y xzx

zx

′

()

=

()

′

()

(

)

=

fxyz

,,

(16.83)

()

()

Given initial conditions

, we can solve this system us-

ing Euler's method by applying the following step formula.

y x

=

y

and

zx

=

z

0

0

0

0

Search Nedrilad ::

Custom Search