Graphics Reference
In-Depth Information
the mouse-click selection operation , our program must perform the following.
Mouse-click position.
Mouse-click positions are
often defined in the hard-
ware coordinate space (see
Section 10.5). Once again,
in the following discussion,
we assume that the Hard
wareToDevice() function
has already been called and
that the mouse-click position
is
Coordinate space conversion. As illustrated in Figure 11.19, mouse-click
positions are typically defined in the device coordinate space while primi-
tives of components are usually defined in individual OC spaces. Our pro-
gram must convert these positions into a common coordinate space for the
proximity test.
Proximity test. Our program must determine if the mouse-click position is
within the bounds of or sufficiently close to each graphical object.
defined
in
the
device
coordinate (DC) space.
Coordinate Space Conversion
The problem at hand is that we need to perform proximity tests between the DC
space mouse-click position and the primitive vertices that are in different OC
spaces. The solution, of course, is to transform the mouse-click position and/or
the primitive vertices into a common coordinate space for the proximity tests. In
general, there are three strategies to implement this solution. For the following
discussion, the mouse-click position,
pt dc =(
x dc ,
y dc ) ,
is expressed as a vector,
V dc = x dc y dc .
M d 2 w . This is the DC-to-WC
transform as defined by Equa-
tion (10.17) on p. 288.
M b ,M la ,M lp . These are
the transformation matrices
of the Body , LeftArm ,and
LeftPalm as illustrated in Fig-
ure 11.14
1. Only transform mouse-click position. Transform the mouse-click posi-
tion to each of the OC spaces for proximity test.
For example, in Fig-
ure 11.19 we compute the following.
Body OC space. Transform V dc to the body's OC space by
M b ) 1
V b
=
V dc M d 2 w (
V dc M d 2 w M 1
=
b
and use V b (or pt b ) for performing proximity tests with the vertices of
pt b =( x b , y b ) .
V b = x b y b .
C b 0 and R b 1 .
Left arm OC space. Transform V dc to the left arm's OC space by
M la M b ) 1
V la
=
V dc M d 2 w (
V dc M d 2 w M 1
b
M 1
la
=
and use V la (or pt la ) for performing proximity tests with the vertices
pt la =( x la , y la ) .
V la = x la y la .
of R a 0 , R a 1 ,and R a 2 .
Search WWH ::




Custom Search