Computer Graphics Unit 5

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

BCA414: COMPUTER GRAPHICS 1

UNIT V

TOPICS COVERED:

2-D Viewing- The viewing pipeline. Viewing co-ordinate, Reference Frame.


Window to viewports co-ordinate transformation, 2-D Viewing functions.
Clipping operations point clipping, Cohen- Sutherland Line Clipping
algorithm, Sutherland Hodgmann polygon clipping algorithm.

2-D Viewing

Two-dimension viewing in Computer graphics is a technique to map the world


coordinates system (actual coordinates of the object in the real world) to device
coordinates (actual coordinates of the object on the output screen like a monitor).

Types of Coordinate Systems:

Cartesian This is the most commonly used


Coordinate coordinate system in which points are
System represented by an ordered pair (x, y)
or triple (x, y, z) representing their
horizontal and vertical distances from
a fixed point called the origin. The
axes are perpendicular to each other
and labeled as X, Y, and Z for three-
dimensional space.

World Also known as global coordinates,


Coordinate world coordinates represent positions
System within a larger context like maps or
virtual environments. Typically
defined relative to some agreed-upon
zero point outside the immediate
object or scene being modeled. For

TS
BCA414: COMPUTER GRAPHICS 2
UNIT V

example, in a 3D game, the entire


game level could be considered the
"world," and all objects within it would
have their own local coordinates,
referenced to the world coordinates.
Object/ Refers to the internal coordinate system of a physical device, such as a
Device computer monitor, camera sensor, or scanner bed. Each pixel has its
Coordinate unique location within this grid, allowing precise addressing during data
System acquisition or rendering processes.

Normalized Normalizing coordinates means


Coordinate adjusting them so they fall within a
System specific range, often between 0 and 1
or -1 and +1. This process helps
eliminate variations due to
differences in scale, resolution, or
aspect ratio among various devices
or representations. By normalizing
coordinates, one can easily compare
or combine data without worrying
about these discrepancies.

An example is normalized screen


coordinates, where (0,0) represents
the top-left corner and (1,1)
corresponds to the bottom-right
corner regardless of actual display
size or resolution.

2D Viewing Pipeline:

This involves a series of transformations performed, right from creation, till the object
is finally seen or displayed at a position or a viewing region on a display device like
monitor. Each transformation step performed converts data from one coordinate
system to the other.

TS
BCA414: COMPUTER GRAPHICS 3
UNIT V

TS
BCA414: COMPUTER GRAPHICS 4
UNIT V

TS
BCA414: COMPUTER GRAPHICS 5
UNIT V

TS
BCA414: COMPUTER GRAPHICS 6
UNIT V

“The viewport can be defined as an area on the screen which is used to display the
object.” The window is an area space for the object. Viewport surrounds the object.
We need the coordinate transformation to display the object on the screen. We can
define many viewports on a different area of the screen and also see the same object
from a different angle in the viewport.

TS
BCA414: COMPUTER GRAPHICS 7
UNIT V

TS
BCA414: COMPUTER GRAPHICS 8
UNIT V

TS
BCA414: COMPUTER GRAPHICS 9
UNIT V

TS
BCA414: COMPUTER GRAPHICS 10
UNIT V

Window to view port co-ordinate transformation

n Computer Graphics terminology, a window is a rectangular region of interest, and


a viewport is a display area chosen on the monitor screen for viewing the contents
of the window. In short, window is ‘what we want to see’ and viewport is ‘where
we want to see’. As shown in the figure below, we can define a rectangular region
in the world coordinate system, and call that as window. The contents of the
window are to be mapped to a region or a display area chosen as viewport. In a
way this is, mapping contents between two rectangular regions of different
dimensions. Window is generally defined in the world coordinate system, while
viewport is defined in the end device coordinate system. Since we wish to convert
data to device independent or normalized coordinates, we perform window-
viewport transformation. So in window-viewport transformation contents of the
window are mapped to normalized coordinates (coordinates between 0 and 1).

For simplicity, both window and viewport are chosen to be rectangular in shape
whose boundaries are aligned with the coordinate axes. Because the dimensions of
window and viewport are different, we will be performing a scaling like operation.
If the window is bigger in size than the viewport, we perform a scale down
operation and vice-versa. As you can notice from the figure above, the boundaries
of the window and viewport are defined by four infinitely extending lines parallel
to the coordinate axes. The window boundaries are defined by the four lines,
xwmin, xwmax, ywmin, yWmax. Where xwmin, xwmax define the two vertical
boundaries, while, ywmin and ywmax define the two horizontal boundaries of the
window. Similarly the viewport boundaries are defined by four infinitely extending
lines, xvmin, xvmax, yvmin, yvmax.

Now for a point (xw,yw) in the window, we have to identify an equivalent point in
the viewport, say (xv,yv). i.e., for every point in the window, there is an equivalent
point in the viewport. The four corner vertices of the window have got their
equivalent vertex points in the viewport, which are nothing but the four corner
points of the viewport. For the point (xwmin, ywmin) in the window, the equivalent
point in the viewport is (xvmin, yvmin) and so on.

TS
BCA414: COMPUTER GRAPHICS 11
UNIT V

TS
BCA414: COMPUTER GRAPHICS 12
UNIT V

TS
BCA414: COMPUTER GRAPHICS 13
UNIT V

TS
BCA414: COMPUTER GRAPHICS 14
UNIT V

Clipping

TS
BCA414: COMPUTER GRAPHICS 15
UNIT V

TS
BCA414: COMPUTER GRAPHICS 16
UNIT V

TS
BCA414: COMPUTER GRAPHICS 17
UNIT V

TS
BCA414: COMPUTER GRAPHICS 18
UNIT V

TS
BCA414: COMPUTER GRAPHICS 19
UNIT V

TS
BCA414: COMPUTER GRAPHICS 20
UNIT V

TS
BCA414: COMPUTER GRAPHICS 21
UNIT V

TS
BCA414: COMPUTER GRAPHICS 22
UNIT V

TS
BCA414: COMPUTER GRAPHICS 23
UNIT V

TS

You might also like