
1
CS 430/536
Computer Graphics I
Line Clipping
2D Transformations
Week 2, Lecture 3
David Breen, William Regli and Maxim Peysakhov
Geometric and Intelligent Computing Laboratory
Department of Computer Science
Drexel University
http://gicl.cs.drexel.edu
2
Overview
• Cohen-Sutherland Line Clipping
• Parametric Line Clipping
• 2D Affine transformations
• Homogeneous coordinates
• Discussion of homework #1
Lecture Credits: Most pictures are from Foley/VanDam;
Additional and extensive thanks also goes to those
credited on individual slides
3
Scissoring Clipping
Pics/Math courtesy of Dave Mount @ UMD-CP
Performed during scan conversion of the
line (circle, polygon)
Compute the next point (x,y)
If xmin
≤
x
≤
xmax and ymin
≤
y
≤
ymax
Then output the point.
Else do nothing
• Issues with scissoring:
– Too slow
– Does more work then necessary
• Better to clip lines to window, than “draw”
lines that are outside of window
4
The Cohen-Sutherland Line
Clipping Algorithm
• How to clip lines to fit in
windows?
– easy to tell if whole line
falls w/in window
– harder to tell what part
falls inside
• Consider a straight line
• And window:
Pics/Math courtesy of Dave Mount @ UMD-CP
5
Cohen-Sutherland
Basic Idea:
• First, do easy test
– completely inside or
outside the box?
• If no, we need a
more complex test
• Note: we will also
need to figure out
how line intersects
the box
Pics/Math courtesy of Dave Mount @ UMD-CP
6
Cohen-Sutherland
Perform trivial accept and reject
• Assign each end point a location code
• Perform bitwise logical operations on a
line’s location codes
• Accept or reject based on result
• Frequently provides no information
– Then perform more complex line intersection