Graphics Reference
In-Depth Information
When generalizing from 2D to 3D, we lost the ability to describe rotation with
a simple number: instead, we can only describe rotation by a general operator, a
matrix in this case.
Tutorial 16.3.
Project Name:
D3D _ RotateMatrix
Library Support:
UWB _ MFC _ Lib1
UWB _ D3D _ Lib16
Tutorial 16.3. Working with Rotation Matrix Representation
Goal. Demonstrate working with the new matrix rotation operator and un-
derstand that the UI controls must report changes in rotation instead of ab-
solute amounts of rotation.
Approach. Work with the scene from from Tutorial 16.2 and identify the
difference in implementation.
Figure 16.5 is a screenshot of running Tutorial 16.3. This tutorial is implemented
based on the matrix rotation representation. Now, select the tiger mesh scene
node and click on the “Rotate” radio button to set the slider bars to control ro-
tations. Adjust the slider bars to notice how the tiger's orientation maintains a
constant relationship to the major axes. This constant relationship allows a con-
tinuous intuitive manipulation of the tiger's orientation. In this case, we can as-
sociate the up direction of the tiger to the y -axis direction, the front of the tiger
to the
Figure 16.5.
Tutorial
16.3.
z -axis direction, and the right side of the tiger to the x -axis direction. We
can always rotate with respect to y -axis to change the front-facing direction of
the tiger. We see that we do not result in gimbal lock by concatenating rotation
operators.
Click on the “Reset” button to reset the tiger to the initial orientation. Now,
perform the following 4 rotations in order: (1) set the x slider bar to any value (
θ 1 ),
(2) set the y slider bar to any value (
θ 2 ), (3) set the x slider bar back to around zero
(
θ 1 ), and finally (4) set the y slider bar back to around zero (
θ 2 ). The rotations
we have performed are
R y
R x
R y
R x
R a =
( θ 2 )
( θ 1 )
( θ 2 )
( θ 1 ) .
Clearly this is not a zero rotation, and the tiger's orientation verifies our obser-
vation. However, notice that all three rotation slider bars report 0 rotations. This
exercise reaffirms the fact that with the matrix rotation representation, the rotation
slider bars are simply a mechanism for specifying changes in rotation and not for
reporting the state of the rotation. Listing 16.11 shows our implementation of
computing slider bar position changes. At label A are the variables for record-
ing existing values of rotation slider positions. At label B, in the OnHScroll()
slider bar service routine, the changes in slider bar position are computed ( dx )and
reported to XformInfo for updating the rotation matrix.
Search WWH ::




Custom Search