Graphics Programs Reference
In-Depth Information
If the origin is at the bottom left corner, then
s x = (half the screen width) + (half the screen width)
×
c x ,
s y = (half the screen height) + (half the screen height)
×
c y .
If it is at the top left corner,
s x = (half the screen width) + (half the screen width)
×
c x ,
s y = (half the screen height)
(half the screen height)
×
c y .
Example . We apply the method above to the standard case depicted in Fig-
ure 3.22, where the screen is part of the xy plane and is centered on the origin and the
viewer is located k units from the origin on the negative z axis. Assuming that the two
half-angles h and v are given, we need to compute scale factors c x and c y that will make
it possible to determine for any given point P whether its projection on the xy plane is
inside or outside the screen.
It is clear that b =(0 , 0 ,
b . We also select the positive y
direction as our “up” direction, so Z =(0 , 1 , 0). To express the final results in a general
way, we denote m =tan h and n =tan v . The calculation is straightforward.
1. U = a × Z =(0 , 0 ,k ) × (0 , 1 , 0) = ( −k, 0 , 0).
2. W = U
k )and a =(0 , 0 ,k )=
(0 , 0 ,k )=(0 ,k 2 , 0).
3. C = b + a =(0 , 0 , 0). The center of the screen is at the origin.
4. The local screen axes are
×
a =(
k, 0 , 0)
×
U
W
u =
| |
a
|
tan h =(
km, 0 , 0) ,
w =
| |
a
|
tan v =(0 ,kn, 0) .
|
U
|
W
5. The three quantities α , d ,and c are determined next:
2
k 2
|
a
|
k
z + k ,
α =
b ) =
( x, y, z + k ) =
a
( P
(0 , 0 ,k )
k
z + k ( x, y, z + k )=
k
z + k ( x, y, 0) ,
d = b + α ( P b )=(0 , 0 ,k )+
c = α ( P b ) a = α ( P b )+ b = d .
6. The scale factors c x and c y can now be obtained:
k
z + k (
xkm )
k 2 m 2
c x = c
u
x
m ( z + k ) ,
=
=
| u |
2
(3.18)
k
z + k ( ykn )
k 2 n 2
c y = c
w
y
n ( z + k ) .
=
=
|
w
|
2
 
Search WWH ::




Custom Search