Game Development Reference
In-Depth Information
Figure 8.2: Reflection about an arbitrary
plane. Note that
k
is the shortest signed
distance from
v
to the plane and
k
is posi-
tive in this figure since
v
lies in the positive
half-space of the plane.
From the “Planes” section in Part I, we know that
q=v
-
k
n
, where
k
is the shortest signed distance from
v
and the plane. It follows then
that the reflection of
v
about the plane (
n
,
d
) is given by:
ˆ
v
v
2
k
n
n
ˆ
ˆ
v
2
n
v
d
n
ˆ
ˆ
ˆ
v
2
n
v
n
d
We can represent this transformation from
v
to
v
with the following
matrix:
2
n
n
1
2
n
n
2
n
n
0
x
x
y
x
z
x
2
n
n
2
n
n
1
2
n
n
0
x
y
y
y
z
y
R
2
n
n
2
n
n
2
n
n
1
0
x
z
y
z
z
z
2
n
d
2
n
d
2
n
d
1
x
y
z
The D3DX library provides the following function to create the reflec-
tion matrix as shown by
R
about an arbitrary plane:
D3DXMATRIX *D3DXMatrixReflect(
D3DXMATRIX *pOut, // The resulting reflection matrix.
CONST D3DXPLANE *pPlane // The plane to reflect about.
);
Since we are on the topic of reflection transformations, let's present the
matrices representing three other special case reflection transforma-
tions. They are the reflections about the three standard coordinate
planes—the yz plane, xz plane, and xy plane—and are represented by
the following three matrices, respectively:
Search WWH ::
Custom Search