Game Development Reference
In-Depth Information
terms of α, and then substitute in θ:
cos 2α = 1 − 2 sin 2 α,
cosθ = 1 − 2 sin 2 (θ/2).
(8.17)
Substituting for cosθ in Equation (8.17), we have
m 11 = 1 − (1 − n x 2 )(1 − cosθ)
= 1 − (1 − n x 2 )
1 − 2 sin 2 (θ/2)
1 −
= 1 − (1 − n x 2 )
2 sin 2 (θ/2)
.
Now we use the fact that since n is a unit vector, n x 2 +n y 2 +n z 2 = 1, and
therefore 1 − n x 2 = n y 2 + n z 2 :
m 11 = 1 − (1 − n x 2 )
2 sin 2 (θ/2)
= 1 − (n y 2 + n z 2 )
2 sin 2 (θ/2)
= 1 − 2n y 2 sin 2 (θ/2) − 2n z 2 sin 2 (θ/2)
= 1 − 2y 2 − 2z 2 .
Elements m 22 and m 33 are derived in a similar fashion. The results are
presented at the end of this section when we give the complete matrix in
Equation (8.20).
Now let's look at the nondiagonal elements of the matrix; they are easier
than the diagonal elements. We'll use m 12 as an example:
m 12 = n x n y (1 − cosθ) + n z sinθ.
(8.18)
We use the reverse of the double-angle formula for sine (see Section 1.4.5):
sin 2α = 2 sinαcosα,
sinθ = 2 sin(θ/2) cos(θ/2).
(8.19)
Now we substitute Equations (8.17) and (8.19) into Equation (8.18) and
simplify:
m 12 = n x n y (1 − cosθ) + n z sinθ
= n x n y
1 − 2 sin 2 (θ/2)
1 −
+ n z (2 sin(θ/2) cos(θ/2))
2 sin 2 (θ/2)
= n x n y
+ 2n z sin(θ/2) cos(θ/2)
= 2 (n x sin(θ/2)) (n y sin(θ/2)) + 2 cos(θ/2) (n z sin(θ/2))
= 2xy + 2wz.
The other nondiagonal elements are derived in a similar fashion.
Search WWH ::




Custom Search