Game Development Reference
In-Depth Information
The first two rows of the matrix M represent the equations
b xcx r
+=
(16.28)
11
1 2
1
and
ax
++=
bx
cx
r
.
(16.29)
21
2 2
23
2
We can solve Equation (16.28) for x and substitute the result into Equation
(16.29) to obtain
c
r
1
1
ba
xcxra
+
=
,
(16.30)
2
2
2
2
3
2
2
b
b
1
1
which now contains only two unknowns instead of three. Continuing this pro-
cess, we can write each of the equations as
β xcx ρ
+
=
,
(16.31)
ii
ii
+
1
i
where
β and ρ are constants given by the recurrence formulas
c
β ba β
ρ
ρ ra β
i
1
=−
i
i
i
i
1
i
1
=−
.
(16.32)
i
i
i
i
1
The equation corresponding to the last row of the matrix M becomes
β x ρ
=
,
nn
n
giving us the value of x :
ρ
n
x
=
.
(16.33)
n
β
n
Plugging this value back into Equation (16.31) for
=−
n
1
gives us the value of
i
x
, and in general,
n
1
ρ c
i
i
x
=−
x
.
(16.34)
i
ββ +
i
1
i
i
An implementation of this algorithm is shown in Listing 16.6. The algorithm
is begun with 1
c β calculated with Equation
(16.32) is saved for later use in Equation (16.34). This implementation assumes
β b
=
and 1
ρ r
=
. Each value of i
1
1
i
Search Nedrilad ::




Custom Search