Graphics Reference
In-Depth Information
the matrices you encounter, with the first matrix being farthest to the right; reading
downward, you accumulate their inverses in the opposite order. When we build
scene graphs in 3D, exactly the same rules apply.
For a 3D scene, there's the description not only of the model, but also of how
to transform points of the model into points on the display. This latter description
is provided by specifying a camera. But even in 2D, there's something closely
analogous: The Canvas in which we created our clock model corresponds to the
“world” of a 3D scene; the way that we transform this world to make it appear on
the display (scale by ( 4.8, 4.8 ) and then translate by ( 48, 48 ) ) corresponds to the
viewing transformation performed by a 3D camera.
Typically the polygon coordinates (the ones we've placed in templates) are
called modeling coordinates. Given the analogy to 3D, we can call the canvas
coordinates world coordinates, while the WPF coordinates can be called image
coordinates. These terms are all in common use when discussing 3D scene graphs.
As an exercise, let's consider the tip of the hour hand; in modeling coordinates
(i.e., in the clock-hand template) the tip is located at ( 0, 9 ) .Inthesameway,the
tip of the minute hand, in modeling coordinates, is at ( 0, 9 ) . What are the Canvas
coordinates of the tip of the hour hand? We must multiply (reading from leaf
toward root) by all the transformation matrices from the hour-hand template up to
the Canvas , resulting in
0.96
0.26
0
100
0
1.7 0 0
0 .70
001
0
9
1
0.26
0.96
0
10
001
(10.91)
0
0
1
1.64
.18
0
0
9
1
1.63
=
,
=
0.44
0.68
0
6.09
1
(10.92)
001
where all coordinates have been rounded to two decimal places for clarity. The
Canvas coordinates of the tip of the minute hand are
=
.
100
0
100
0
0
9
1
0
9
1
10
001
10
001
(10.93)
We can thus compute a vector from the hour hand's tip to the minute hand's
tip by subtracting these two, getting
0 T . The result is the
1.63
15.08
homogeneous-coordinate representation of the vector
15.08 T in Canvas
1.63
coordinates.
Suppose that we wanted to know the direction from the tip of the minute hand
to the tip of the hour hand in minute-hand coordinates. If we knew this direction,
we could add, within the minute-hand part of the model, a small arrow that pointed
toward the hour-hand. To find this direction vector, we need to know the coordi-
nates of the tip of the hour hand in minute-hand coordinates. So we must go from
hour-hand coordinates to minute-hand coordinates, which we can do by working
up the tree from the hour hand to the Canvas , and then back down to the minute
hand. The location of the hour-hand tip, in minute-hand coordinates, is given by
 
Search WWH ::




Custom Search