0% found this document useful (0 votes)
22 views

Lecture 3_ Graphical Systems, Transformation & Clipping

The document outlines the components and processes involved in computer graphical systems, specifically focusing on coordinate systems, clipping algorithms, and transformations between windows and viewports. It details various clipping techniques such as point, line, and polygon clipping, including specific algorithms like Cohen-Sutherland and Sutherland-Hodgeman. Additionally, it discusses the applications of clipping in graphical displays and the importance of efficient algorithms in rendering graphics accurately.

Uploaded by

iamkarue
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)
22 views

Lecture 3_ Graphical Systems, Transformation & Clipping

The document outlines the components and processes involved in computer graphical systems, specifically focusing on coordinate systems, clipping algorithms, and transformations between windows and viewports. It details various clipping techniques such as point, line, and polygon clipping, including specific algorithms like Cohen-Sutherland and Sutherland-Hodgeman. Additionally, it discusses the applications of clipping in graphical displays and the importance of efficient algorithms in rendering graphics accurately.

Uploaded by

iamkarue
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/ 45

BCT 2405 Computer Graphical systems

Karanja Mwangi
Lesson objective

 At the end of this class you will


 Describe various components of coordinate systems used in
computer graphics pipelining
 Understand the role of clipping algorithms
 Appreciate various clipping algorithms
Outline

 The viewing pipeline


 Viewing coordinate reference frame
 Window-to-viewport coordinate transformation
 Point clipping
 Line clipping
 Polygon clipping
Window and Viewport
 Window: Area selected in world-coordinate for display is called
window. It defines what is to be viewed.
 Viewport: Area on a display device in which window image is
display (mapped) is called viewport. It defines where to display.

Window
YWmax

Viewport
YVmax

YWmin YVmin

XWmin XWmax XVmin XVmax


The Viewing Pipeline (2 D pipelining)
 In many case window and viewport are rectangle, also other
shape may be used as window and viewport.
 In general finding device coordinates of viewport from world
coordinates of window is called as viewing transformation.
 Sometimes we consider this viewing transformation as window-to-
viewport transformation but in general it involves more steps.
 Let’s see steps involved in viewing pipeline.
Contd.
Construct World- Convert
Coordinate Scene World-
MC Using Modeling- WC Coordinate to
Coordinate Viewing
Transformations Coordinates

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

ywmax Clipping Window

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.

If result of logical AND is non-zero


Line is completely outside the clipping window.
Otherwise
Calculate the intersection point with the boundary one by one.
Divide the line into two parts from intersection point.
Repeat from Step-1 for both line segments.
Step-3:
Draw line segment which are completely inside and eliminate other line segment
which found completely outside.
Intersection points- Cohen-Sutherland
Algorithm
Contd.
Liang-Barsky Line Clipping
Liang-Barsky Line Clipping
Algorithm
Advantages of Liang-Barsky Line
Clipping
Nicholl-Lee-Nicholl Line (NLN)
Clipping
 By creating more regions around the clip window the NLN
algorithm avoids multiple clipping of an individual line segment.
 In Cohen-Sutherlan line clipping sometimes multiple calculation of
intersection point of a line is done before actual window boundary
intersection.
 These multiple intersection calculation is avoided in NLN line
clipping procedure.
 NLN line clipping perform the fewer comparisons and divisions so
it is more efficient.
 But NLN line clipping cannot be extended for three dimensions.
Contd.
 For given line we find first point falls in which region out of nine
region shown in figure.
 Only three region are considered which are.
• Window region
• Edge region
• Corner region

 If point falls in other region than we transfer that point in one of


the three region by using transformations.
 We can also extend this procedure for all nine regions.
Dividing Region in NLN

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

 Four possible cases are there. B C


1. If both vertices are inside the window we add only second
vertices to output list.
2. If first vertices is inside the boundary and second vertices is
outside the boundary only the edge intersection with the window
boundary is added to the output vertex list.
3. If both vertices are outside the window boundary nothing is
added to window boundary.
4. first vertex is outside and second vertex is inside the boundary,
then adds both intersection point with window boundary, and
second vertex to the output list.
Example
3
2’
2 1’

1 4

6
5

 As shown in figure we clip against left boundary.


 Vertices 1 and 2 are found to be on the outside of the boundary.
 Then we move to vertex 3, which is inside, we calculate the
intersection and add both intersection point and vertex 3 to
output list.
Contd.
3
2’
2 1’

1 3’ 4

6 5’
4’
5

 Then we move to vertex 4 in which vertex 3 and 4 both are inside


so we add vertex 4 to output list.
 Similarly from 4 to 5 we add 5 to output list.
 From 5 to 6 we move inside to outside so we add intersection pint
to output list.
 Finally 6 to 1 both vertex are outside the window so we does not
add anything.
Limitation of Sutherlan-Hodgeman Algorithm

 It may not clip concave polygon properly.


V2

V3
V1
V4

V5
V6

 One possible solution is to divide polygon into numbers of


small convex polygon and then process one by one.
 Another approach is to use Weiler-Atherton algorithm.
Weiler-Atherton Polygon Clipping

 It modifies Sutherland-Hodgeman vertex processing


procedure for window boundary so that concave polygon
also clip correctly.
 This can be applied for arbitrary polygon clipping regions
as it is developed for visible surface identification.
 Procedure is similar to Sutherland-Hodgeman algorithm.
 Only change is sometimes need to follow the window
boundaries Instead of always follow polygon boundaries.
 For clockwise processing of polygon vertices we use the
following rules:
1. For an outside to inside pair of vertices, follow the polygon
boundary.
2. For an inside to outside pair of vertices, follow the window
boundary in a clockwise direction.
V2 V
Example V1 ’
2


V3
V1 V4 V3
V4 ’ ’

V5
V6

 Start from v1 and move clockwise towards v2 and add


intersection point and next point to output list by following
polygon boundary,
 then from v2 to v3 we add v3 to output list.
 From v3 to v4 we calculate intersection point and add to output
list and follow window boundary.
V2 V
Contd. V1 ’
2


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.

You might also like