Graphics Reference
In-Depth Information
UWBGL_D3D_Lib16
Change summary.
See p. 531
for a summary of changes to
the library.
To properly support the concatenation operations as described by Equation (16.2),
the
Lib16
library defines an explicit rotation operator (matrix) in the
XformInfo
class. This matrix replaces the three floating-point numbers that represented the
Euler angles. Listing 16.9 shows the updated
XformInfo
class where at label C
we define a 3
3 matrix to replace the previous three floating-point numbers. At
label A and label A1, we see that in this case, the matrix is initialized with the
identity matrix (
I
3
). The function at label B is designed to allow the user to adjust
rotation in the
x
-axis by
dx
(
R
x
×
(
dx
)
). In this case we must compute
R
x
m
_
rotation
=
(
dx
)
×
m
_
rotation
.
At label B1, we use the variable
m
to represent the rotation operator
R
x
.Atla-
bel B2, we compute the content of the operator
R
x
(
dx
)
.
At label B3, the new
rotation operation is concatenated with the
XformInfo
.
It is important to notice that the rotation matrix in
XformInfo
is an ordered
concatenation of all rotation requests. In this case, we do not know the individual
steps by which to arrive at this rotation. In addition, we do not have a simple user-
class
UWB
_
XformInfo {
Source file.
uwbgl
_
XformInfo4.h/cpp
file in the
Common Files/
XformInfo
subfolder of the
UWBGL
_
D3D
_
Lib16
project.
public
:
A:
void
InitializeRotation();
// initialize rotation
.
B:
void
UpdateRotationXByDegree(dx);
// update rotaion by dx about
x
axis
.
protected
:
C:
mat3
m
_
rotation;
// A
3
x
3
matrix
.
void
UWB
_
XformInfo::InitializeRotation()
A1:
makeIdentity(m
_
rotation);
// initialize to identity (
I
3
)
void
UWB
_
XformInfo::UpdateRotationXByRadian(
float
dx)
B1:
mat3
m;
// a
3
x
3
matrix
// compute
R
x
(
dx
)
B2:
m[1][1]=...; m[1][2]=...
B3:
m
_
rotation = m
*
m
_
rotation;
// concatenate
R
x
(
dx
)
with the
3
x
3
matrix
Listing 16.9.
Supporting 3D rotation with explicit matrix representation.
Search WWH ::
Custom Search