Window-to-Viewport Transformation


 
Window-to-Viewport
Transformation

 
Objects and primitives in the application model will be stored in world coordinates. To display the appropriate images on screen it is necessary to map world coordinates to screen or device coordinates. This transformation is known as window-to-viewport transformation.

 
Window - Area that defines what is to be displayed.
Viewport - Area that defines where it is to be displayed.



The window in world coordinates and the viewport in screen coordinates

 
Whatever area is selected in the window is sent to the viewport. The size of the viewport might be smaller or larger than the window.




Window-to-Viewport transformation example

 
The window-to-viewport transformation maintains the relative position of a point in window as well as in the viewport. A point at position (xw,yw) in the window is mapped into position (xv,yv) in the associated viewport.





 
Point (xw,yw) in window is mapped to viewport coordinates (xv,yv); the relative position of the point in the two areas is the same.

 
The inputs to this transformation are window-size and viewport-size. The following steps are involved in the transformation:
             1. Translation 2. Scaling     3. Inverse Translation

 
 
To maintain the same relative placement in the viewport as in the window, the following conditions must be satisfied:

 

 
(1)

 

 

 

 
(2)

 

 

 
Solving (1) and (2) for the viewport position (xv,yv), we have

 

 

 
where the scaling factors sx and sy are,

 

 

 

 

 

 

 

 

 
The transformation matrix that maps the window from world coordinates into the viewport in screen coordinates can be developed from the above equations. The overall matrix is:


5 comments:

  1. thanku sir it helps me alot... Its now clear....

    ReplyDelete
  2. thanks a lot..i got this just before my final exam..

    ReplyDelete
  3. Hey Your equation 1 and equation2 are invisible.Unable to see anything.

    ReplyDelete
  4. it is helpful to me...got this before my final exams :)

    ReplyDelete