Game Engine Architecture

(Ben Green) #1

164 4. 3D Math for Games


In this equation,
z iC is the unit basis vector along the child space x-axis, expressed in par-
ent space coordinates;
z jC is the unit basis vector along the child space y-axis, in parent space;
z kC is the unit basis vector along the child space z-axis, in parent space;
z tC is the translation of the child coordinate system relative to parent
space.
This result should not be too surprising. The tC vector is just the transla-
tion of the child space axes relative to parent space, so if the rest of the ma-
trix were identity, the point (0, 0, 0) in child space would become tC in parent
space, just as we’d expect. The iC , jC , and kC unit vectors form the upper 3 × 3
of the matrix, which is a pure rotation matrix because these vectors are of unit
length. We can see this more clearly by considering a simple example, such as
a situation in which child space is rotated by an angle γ about the z-axis, with
no translation. The matrix for such a rotation is given by

(4.2)


But in Figure 4.20, we can see that the coordinates of the iC and jC vectors,
expressed in parent space, are iC = [ cos γ sin γ 0 ] and jC = [ –sin γ cos γ 0 ].
When we plug these vectors into our formula for MCP→ , with kC = [ 0 0 1 ], it
exactly matches the matrix rotatez(r, γ) from Equation (4.2).

Scaling the Child Axes
Scaling of the child coordinate system is accomplished by simply scaling the
unit basis vectors appropriately. For example, if child space is scaled up by a

cos sin 0 0
sin cos 0 0
rotate ( , ) [ 1]. 0 0 10

0 0 01

z rrrxyz

⎡⎤γγ
⎢⎥−γ γ
γ= ⎢⎥
⎢⎥
⎢⎥
⎣⎦

r

CP

; 0 0 0 0 0 0


0.


1


P C CP
C
C
C
C
Cx Cy Cz
Cx Cy Cz
Cx Cy Cz
Cx Cy Cz

iii
jjj
kkk
t



=


⎡⎤


⎢⎥


=⎢⎥


⎢⎥


⎢⎥


⎣⎦


⎡⎤


⎢⎥


=⎢⎥


⎢⎥


⎢⎥


⎣⎦


P PM


i
j
M k

t

tt
Free download pdf