Graphics Programs Reference
In-Depth Information
d
P
from origin
w
φ
c
θ
Z
W
v
b
u
a
h
Viewer
U
Figure 3.38: A Viewing Geometry.
We proceed in the following simple steps:
1. Calculate vector
U
as perpendicular to both
a
and
Z
.
U
=
a
×
Z
.
a
. Vector
W
is in the
Za
plane and is perpendicular to
a
. It will serve to determine vector
w
on the
screen in step 4.
3. Denote
C
=
b
+
a
. This points to the center of the screen.
4. Construct the half-screen vectors
u
and
w
. They are in the directions of
U
and
W
, respectively, but their sizes are determined by the viewing angles
2. Compute vector
W
as perpendicular to both
U
and
a
.
W
=
U
×
U
|
U
|
|
a
|
tan
h,
W
|
W
|
|
a
|
tan
v.
u
=
w
=
|
a
|
2
a
•
(
P
−
b
)
5. Compute
α
=
and vectors
d
=
b
+
α
(
P
−
b
)and
c
=
α
(
P
−
b
)
−
a
in
the usual way.
6. Now that
c
is known, we use it to determine the two scale factors
c
x
and
c
y
:
c
x
=
|
c
|
cos
θ
|
1
c
y
=
|
c
|
cos
φ
1
=
2
(
c
•
u
)
,
=
2
(
c
•
w
)
.
u
|
|
u
|
|
w
|
|
w
|
These are numbers in the range [
−
1
,
1]. Any point
P
=(
x, y, z
) for which either
c
x
or
c
y
is greater than 1 or less than
−
1 is therefore outside the screen and should not be
displayed.
The range of values of
c
x
and
c
y
assumes that the origin of the screen is at its
center. The actual screen coordinates (
s
x
,s
y
) of a pixel depend on the dimensions of
the screen (measured in pixels). They are given by
s
x
= (half the screen width)
×
c
x
,
y
= (half the screen height)
×
c
y
.
Search WWH ::
Custom Search