0% found this document useful (0 votes)
48 views4 pages

Unit - 3 Window & View Port CGM

The document discusses windows, viewports, and transformations between them in computer graphics. A window defines a region in world coordinates, while a viewport defines where that region will be displayed. The transformation scales points from window to viewport coordinates using scaling factors along the x and y axes. Clipping identifies parts of an image that are inside or outside the viewport and displays or discards points accordingly.

Uploaded by

manyasharma1298
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views4 pages

Unit - 3 Window & View Port CGM

The document discusses windows, viewports, and transformations between them in computer graphics. A window defines a region in world coordinates, while a viewport defines where that region will be displayed. The transformation scales points from window to viewport coordinates using scaling factors along the x and y axes. Clipping identifies parts of an image that are inside or outside the viewport and displays or discards points accordingly.

Uploaded by

manyasharma1298
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

UNIT – 3 (Computer Graphic’s)

Window:
1. A world-coordinate area selected for display is called a window.
2. In computer graphics, a window is a graphical control element.
3. It consists of a visual area containing some of the graphical user interface of
the program it belongs to and is framed by a window decoration.
4. A window defines a rectangular area in world coordinates. You define a
window with a GWINDOW statement. You can define the window to be larger
than, the same size as, or smaller than the actual range of data values,
depending on whether you want to show all of the data or only part of the
data.
Viewport:
1. An area on a display device to which a window is mapped is called a viewport.
2. A viewport is a polygon viewing region in computer graphics. The viewport is
an area expressed in rendering-device-specific coordinates, e.g. pixels for
screen coordinates, in which the objects of interest are going to be rendered.
3. A viewport defines in normalized coordinates a rectangular area on the
display device where the image of the data appears. You define a viewport
with the GPORT command. You can have your graph take up the entire
display device or show it in only a portion, say the upper-right part.

Window to Viewport Transformation in Computer Graphics with


Implementation: -
Window to Viewport Transformation is the process of transforming a 2D world-
coordinate objects to device coordinates. Objects inside the world or clipping window
are mapped to the viewport which is the area on the screen where world coordinates
are mapped to be displayed.
 World coordinate – It is the Cartesian coordinate w.r.t which we define the
diagram, like Xwmin, Xwmax, Ywmin, Ywmax
 Device Coordinate –It is the screen coordinate where the objects is to be
displayed, like Xvmin, Xvmax, Yvmin, Yvmax
 Window –It is the area on world coordinate selected for display.
 ViewPort –It is the area on device coordinate where graphics is to be
displayed.
Mathematical Calculation of Window to Viewport:
It may be possible that the size of the Viewport is much smaller or greater than the
Window. In these cases, we have to increase or decrease the size of the Window
according to the Viewport and for this, we need some mathematical calculations.
(xw, yw): A point on Window
(xv, yv): Corresponding point on Viewport

 we have to calculate the point (xv, yv)

Now the relative position of the object in Window and Viewport are same.

For x coordinate,

For y coordinate,

so, after calculating for x and y coordinate, we get


where, sx is scaling factor of x coordinate and sy is scaling factor of y coordinate

Example:
Lets assume,
 for window, Xwmin = 20, Xwmax = 80, Ywmin = 40, Ywmax = 80.
 for viewport, Xvmin = 30, Xvmax = 60, Yvmin = 40, Yvmax = 60.
 Now a point ( Xw, Yw ) be ( 30, 80 ) on the window. We have to
calculate that point on viewport
i.e ( Xv, Yv ).
 First of all, calculate scaling factor of x coordinate Sx and scaling
factor of y coordinate Sy using above mentioned formula.
 Sx = ( 60 - 30 ) / ( 80 - 20 ) = 30 / 60
Sy = ( 60 - 40 ) / ( 80 - 40 ) = 20 / 40
 So, now calculate the point on viewport ( Xv, Yv ).
 Xv = 30 + ( 30 - 20 ) * ( 30 / 60 ) = 35
Yv = 40 + ( 80 - 40 ) * ( 20 / 40 ) = 60
 So, the point on window ( Xw, Yw ) = ( 30, 80 ) will be ( Xv, Yv ) = (
35, 60 ) on viewport.

Point Clipping Algorithm in Computer Graphics


Clipping: In computer graphics our screen act as a 2-D coordinate system. it is not
necessary that each and every point can be viewed on our viewing pane(i.e. our
computer screen). We can view points, which lie in particular range (0,0) and (Xmax,
Ymax). So, clipping is a procedure that identifies those portions of a picture that are
either inside or outside of our viewing pane.
In case of point clipping, we only show/print points on our window which are in range
of our viewing pane, others points which are outside the range are discarded.
Example

Point Clipping Algorithm:


1. Get the minimum and maximum coordinates of both viewing pane.
2. Get the coordinates for a point.
3. Check whether given input lies between minimum and maximum coordinate of
viewing pane.
4. If yes display the point which lies inside the region otherwise discard it.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy