Game Development Reference
In-Depth Information
Let's summarize the vectors we have computed:
v
= (
v
n
)
n
,
v
⊥
=
v
−
v
=
v
− (
v
n
)
n
,
w
=
n
×
v
⊥
=
n
×
v
−
v
=
n
×
v
−
n
×
v
=
n
×
v
−
0
=
n
×
v
,
′
⊥
= cosθ
v
⊥
+ sinθ
w
= cosθ (
v
− (
v
n
),
n
) + sinθ (
n
×
v
).
v
′
Substituting for
v
, we have
′
′
v
=
v
⊥
+
v
= cosθ (
v
− (
v
n
)
n
) + sinθ (
n
×
v
) + (
v
n
)
n
.
(5.1)
Equation (5.1) allows us to rotate any arbitrary vector about any arbitrary
axis. We could perform arbitrary rotation transformations armed only with
this equation, so in a sense we are done—the remaining arithmetic is es-
sentially a notational change that expresses Equation (5.1) as a matrix
multiplication.
Now that we have expressed
v
in terms of
v
,
n
, and θ, we can compute
what the basis vectors are after transformation and construct our matrix.
We're just presenting the results here; a reader interested in following each
step can check out Exercise 2.24:
′
2
3
5
T
n
x
2
(1 − cosθ) + cosθ
n
x
n
y
(1 − cosθ) + n
z
sinθ
n
x
n
z
(1 − cosθ) − n
y
sinθ
′
4
p
=
1
0
0
,
p
=
,
2
3
5
T
n
x
n
y
(1 − cosθ) − n
z
sinθ
n
y
2
(1 − cosθ) + cosθ
n
y
n
z
(1 − cosθ) + n
x
sinθ
4
′
q
=
0
1
0
,
q
=
,
2
3
5
T
n
x
n
z
(1 − cosθ) + n
y
sinθ
n
y
n
z
(1 − cosθ) − n
x
sinθ
n
z
2
(1 − cosθ) + cosθ
4
′
r
=
0
0
1
,
r
=
.
Search WWH ::
Custom Search