Lecture 3_ Graphical Systems, Transformation & Clipping
Lecture 3_ Graphical Systems, Transformation & Clipping
Karanja Mwangi
Lesson objective
Window
YWmax
Viewport
YVmax
YWmin YVmin
VC
Map Viewing
Map
Coordinate to
Normalized
Normalized Viewing
NVC Viewport to DC
Coordinates using
Device
Window-Viewport
Coordinates
Specifications
Viewing Coordinate Reference Frame
We can obtain reference frame in any
direction and at any position.
For handling such condition
• first of all we translate reference frame origin
to standard reference frame origin.
• Then we rotate it to align it to standard axis.
Window-To-Viewport Coordinate
Transformation
Mapping of window coordinate to viewport is called window to
viewport transformation.
We do this using transformation that maintains relative position of
window coordinate into viewport.
That means center coordinates in window must be remains at
center position in viewport.
Window
YWmax
YW Viewport
YVmax YV
XW
XV
YWmin YVmin
XWmin XWmax XVmin XVmax
Contd.
Window
YWmax
YW Viewport
YVmax YV
XW
XV
YWmin YVmin
XWmin XWmax XVmin XVmax
Contd.
Contd.
Contd.
Contd.
For each display device we can use different window to viewport
transformation. This mapping is known as workstation
transformation.
Also we can use two different displays devices and we map
different window-to-viewport on each one.
Normalized Space
WS1 Viewport WS2 Viewport
Viewport
Monitor 1 Monitor 2
WS1 Window WS2 Window
Clipping
Any procedure that identifies those portions of a picture that are
either inside or outside of a specified region of space is referred to
as a clipping algorithm, or simply clipping.
The region against which an object is to clip is called a clip
window.
Clip window can be general polygon or it can be curved boundary.
Application of Clipping
It can be used for displaying particular part of the picture on
display screen.
Identifying visible surface in 3D views.
Antialiasing.
Creating objects using solid-modeling procedures.
Displaying multiple windows on same screen.
Drawing and painting.
Point Clipping
ywmin
xwmin xwmax
Full Screen
Line Clipping
Line clipping involves several possible cases.
1. Completely inside the clipping window.
2. Completely outside the clipping window.
3. Partially inside and partially outside the clipping window.
Clipping Window
Full Screen
Line Clipping
For line clipping several scientists tried different methods to solve
this clipping procedure.
Some of them we need to know in this course. Which are:
1. Cohen-Sutherland Line Clipping ( In class)
2. Liang-Barsky Line Clipping (Reading required)
3. Nicholl-Lee-Nicholl Line Clipping (Reading required)
Region Code in Cohen-Sutherland Line
Clipping
This is one of the oldest
and most popular line-
clipping procedures. 1 0 0 1 1 0 0 0 1 0 1 0
In this we divide whole
space into nine region and
Clipping Window
give 4 bit region code.
Code is deriving by:
Also Called autocodes 0 0 0 1 0 0 0 0 0 0 1 0
• Set bit 1: For left side of
clipping window.
• Set bit 2: For right side of
clipping window.
0 1 0 1 0 1 0 0 0 1 1 0
• Set bit 3: For below clipping
window.
• Set bit 4: For above clipping Put all other zero (Reset remaining bit)
window. e.g 1001 (1-top 0-bottom 0-right 1 –
left)
Steps Cohen-Sutherland Line Clipping
Step-1:
Assign region code to both endpoint of a line depending on the position where the
line endpoint is located.
Step-2:
If both endpoint have code ‘0000’
Then line is completely inside.
Otherwise
Perform logical AND between this two codes.
L R
LT
B L
L LR
L
LB
Contd.
L T TR T
T TR
L L
LR
LB LB TB
Finding Region of Given Line in NLN
LT
L
L LR
L
LB
Contd.
LT
L
L LR
L
LB
Intersection Calculation in NLN
Contd.
Polygon Clipping
For polygon clipping we need to modify the line clipping
procedure.
In line clipping we needed to consider about only line segment.
In polygon clipping we need to consider the area and the new
boundary of the polygon after clipping.
Various algorithm available for polygon clipping are:
1. Sutherland-Hodgeman Polygon Clipping (inclass)
2. Weiler-Atherton Polygon Clipping (read)
Sutherland-Hodgeman Polygon
Clipping
For correctly clip a polygon we process the polygon boundary as a
whole against each window edge.
This is done by whole polygon vertices against each clip rectangle
boundary one by one.
Left Right Bottom Top
in out
Clipper Clipper Clipper Clipper
Processing Steps
We process vertices in sequence as a closed Inside Outside
polygon. A D
1 4
6
5
1 3’ 4
6 5’
4’
5
V3
V1
V4
V5
V6
’
V3
V1 V4 V3
V4 ’ ’
V5
V6
’
V3
V1 V4 V3
V4 ’ ’
V5
V
’7 V5
V6 V6
’
’
Similarly from v4 to v5 we add intersection point and next point
and follow the polygon boundary,
next we move v5 to v6 and add intersection point and follow
the window boundary, and
finally v6 to v1 is outside so no need to add anything.
This way we get two separate polygon section after clipping.