This document discusses windowing and clipping in computer graphics. It defines the world coordinate system, which stores graphical information, and the screen coordinate system, which is used for display. A window selects a portion of the model for viewing in the viewport, which is the area on screen where the window is displayed. The window to viewport transformation maps the model from world to screen coordinates using scaling and translation. Clipping removes portions of lines and curves outside the window boundaries. The Sutherland-Cohen algorithm clips lines by calculating intersection points with the window edges.
3. INTRODUCTION
There are two types of coordinate system mainly-
1. World coordinate system
2. Screen coordinate system
1. WORLD COORDINATE SYSTEM
The CAD Software stores graphical information
in the model database with respect to
coordinate system, called WCS or Model
Coordinate System
4. This is the only coordinate system that software
recognizes when storing or retrieving graphical
information from model database.
2) SCREEN COORDINATE SYSTEM
It is the coordinate system which is used to display
screen.
User input the graphical information with respect to this
coordinate system.
It is also known as Working Coordinate System or User
Coordinate System.
5. COORDINATE SYSTEMS
y
x0
(x, y)
World Coordinates:
• User-Defined Limits
• Floating point values
(u,v)
u
v
0
Device Coordinates:
• Device dependent Limits
• Positive Integer values
6. WINDOW AND VIEWPORT
When geometric model is complex and crowded with
intrinsic details, it is difficult to read it. In such
situation, it is convenient to display only certain
portion of geometric model which is of interest of
used at that time.
Here comes, effect of WINDOW and VIEWPORT.
8. WINDOW
It is the portion of geometric model which is selected
for viewing. This technique of selecting portion is called
Windowing.
Generally, window is rectangular in shape with edges
parallel to axes of world coordinate system
It is the finite portion in World Coordinate System.
9. VIEWPORT
Viewport is the part of screen on which window is displayed.
Viewport is also rectangular in shape with its edges parallel to axes
of User coordinate system.
Content of Viewport can be edited in viewport.
By selecting number of windows on geometric model, multiple
viewport can be placed on screen.
11. WINDOW TO VIEWPORT TRANSFORMATION
The mapping of geometric model from world
coordinate system to user coordinate system is
referred as Window to
Viewport transformation or Viewing
transformation.
Transformation is implemented in such a manner
that relative position of all points on object is not
affected.
Viewing transformation can be achieved with the
help of Scaling and Translation.
12. Choose Window in
World Coordinates
Clip to size
of Window
Translate to
origin
Scale to size of Viewport Translate to proper position in image
13. CLIPPING
On Viewport only those entities are supposed to be
visible which are inside the windows in WCS.
If a line is drawn outside the boundaries of window
then it will not be visible in viewport of screen
coordinate system.
Portion which lies outside the boundary of window is
clipped and only the part which lies inside the
boundary of window is visible in viewport.
14.
15. CLIPPING ALGORITHM
1. Identify invisible lines which are completely
outside the boundaries of window.
2. Identify visible lines which lies completely inside
the boundaries of window.
3. The lines which are partially inside and partially
outside the window, only for such lines we find
intersection point of that line with edges of
boundary of window.
17. ALGORITHM FOR CLIPPING LINE
SEGMENT
1. Find 4-bit code for point P1 AND P2.
2. Check whether condition 1 is satisfied or not. If
it is satisfied then, line is visible.
3. If condition 2 is satisfied then line is visible.
4. If both condition 1 and condition 2 are not
satisfied then line is partially visible an partially
invisible. In that case, we find intersection point
of line with edges of window.
18. SUTHERLAND-COHEN CLIPPING
ALGORITHM
It is the oldest and most popular line clipping method.
Generally, this method speeds up the processing of line
segment by performing initial test and reduce number of
intersection that must be calculated.
Here, clipping algorithm is performed with respect to all
edges of window.
19. STEPS OF ALGORITHM
1. Check for completely visible and invisible lines.
Example, if both the endpoints of line are on correct side of
edge then, line is said to be visible while if both the end
points of line segment lies on wrong side of window edge
then it is considered as invisible line.
2. Keep point P1 on correct side of edge always for simplicity
of algorithm. If P1 lies on wrong side of edge then swap P1
and P2.
20.
21. 3. Find the intersection point (P1,P2) with the edges of
window. Denote the intersection point with I.
Clip (P2,I). So that line segment remain is (P1, I).
4. Take line segment (P1, I) for further clipping process.
5. Repeat the whole clipping process with respect to all
different edges of window to get visible line.