Graphics Reference
In-Depth Information
class
CXformInfoControl :
public
CDialog {
.
Source file.
XformInfoControl.h/cpp
files in the
Controls
folder
of the
D3D
_
RotateMatrix
project.
// current sldier bar setting
float
m
_
rx, m
_
ry, m
_
rz;
.
A:
void
CXformInfoControl::OnHScroll( ... ) {
.
// new values from slider bar
float
x=m
_
XSlider.GetSliderValue();
.
switch
(current
_
control)
// when radio button is rotation
case
IDC
_
ROTATE: {
// compute the change in sldier bar position
float
dx=x-m
_
rx;
// remember current position
m
_
rx = x;
// send change in position to set rotation
xform.UpdateRotationXByDegree(dx);
B:
V = (
v
x
,
v
y
,
v
z
)
θ
V
b
.
V
a
q = (V, θ)
Listing 16.11.
Capturing rotation differentials.
Figure 16.6.
The quater-
nion representation of rota-
tion.
UWBGL_D3D_Lib17
Change summary.
See p. 533
for a summary of changes to
the library.
The cost of concatenating operations is the major shortcoming of representing
rotation by an explicit matrix. The
quaternion
offers a storage and computation-
ally efficient alternative to representing rotations. As illustrated in Figure 16.6, a
quaternion describes a rotation with 4 floating-point numbers:
Right-handed rotation di-
rection.
With the right hand,
stick out the thumb and curl
the rest of the fingers into a
“thumbs up” sign. The thumb
direction is along the axis of
rotation, and the rest of the fin-
gers point in the positive direc-
tion of rotation.
V
q
=(
,
θ
)=(
v
x
,
v
y
,
v
z
,
θ
)
,
(16.4)
where
V
is the axis of rotation and
is the angle to rotate. Notice the right-
handed rotation direction and that axes
V
a
and
V
b
are perpendicular to the axis
of rotation
V
. Just as we can describe a series of affine transformations by
concatenating corresponding matrices, a series of rotations can be described by
θ
Search WWH ::
Custom Search