Graphics Reference
In-Depth Information
Figure 4.8.
The window and view-
port rectangles.
tangular window around in it? What is overlooked here is the problem that occurs
when the viewport and the window are not the same size rectangle. For example,
suppose that the window is the square [-2,2] ¥ [-2,2] and that the viewport the rec-
tangle [0,100] ¥ [0,50]. What would happen in this situation is that the circle of radius
1 around the origin in the view plane would map to an ellipse centered at (50,25) in
the viewport. What we know to be a circle in the world would show up visually as an
ellipse on the screen. Would we be happy with that? This is the “aspect ratio” problem.
The reader may have noticed this already when implementing some of the program-
ming projects. What can one do to make circles show up as circles?
The best way to deal with the aspect ratio problem would be to let the user change
the viewport but not the window. The window would then be chosen to match the
viewport appropriately. First of all, users are not interested in such low level concepts
anyway and want to manipulate views in more geometric ways by using commands
like “pan,” “zoom,” “move the camera,” etc. Secondly, in the case of 3d graphics, from
a practical point of view this will in no way affect the program's ability to handle dif-
ferent views. Changing the camera data will have the same effect. In fact, changing
the position and direction of the camera gives the program more control of what one
sees than simply changing the window. Changing the distance that the view plane is
in front of the camera corresponds to zooming. A fixed window would not work in
the case of 2d graphics, however. One would have to let the user translate the window
and change its size to allow zooming. A translation causes no problem, but the
zooming has to be controlled. The size can only be allowed to change by a factor that
preserves the height divided by width ratio. There is no reason for a user to know
what is going on at this level though. As long as the user is given a command option
to zoom in or out, that user will be satisfied and does not need to know any of the
underlying technical details.
Returning to the 3d graphics case, given that our default window will be a fixed
size, what should this size be? First of all, it will be centered about the origin of the
view plane. It should have the same aspect ratio (ratio of height to width) as the view-
port. Therefore, we shall let the window be the rectangle [-1,1] ¥ [-b,b], where b =
(vymax - vymin)/(vxmax - vxmin). Unfortunately, this is not the end of the story. There
is also a hardware aspect ratio one needs to worry about. This refers to the fact that
Search WWH ::




Custom Search