Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that...
-
Upload
randall-weaver -
Category
Documents
-
view
216 -
download
2
Transcript of Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that...
![Page 1: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/1.jpg)
Dr. Scott Schaefer
Clipping Lines
![Page 2: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/2.jpg)
2/94
Why Clip?
We do not want to waste time drawing objects that are outside of viewing window (or clipping window)
![Page 3: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/3.jpg)
3/94
Clipping Points
Given a point (x, y) and clipping window (xmin, ymin), (xmax, ymax), determine if the point should be drawn
(xmin,ymin)
(xmax,ymax)
(x,y)
![Page 4: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/4.jpg)
4/94
Clipping Points
Given a point (x, y) and clipping window (xmin, ymin), (xmax, ymax), determine if the point should be drawn
(xmin,ymin)
(xmax,ymax)
(x,y)
xmin<=x<=xmax?ymin<=y<=ymax?
![Page 5: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/5.jpg)
5/94
Clipping Points
Given a point (x, y) and clipping window (xmin, ymin), (xmax, ymax), determine if the point should be drawn
(x1,y1)(x2,y2)
(xmin,ymin)
(xmax,ymax)
xmin<=x<=xmax?ymin<=y<=ymax?
![Page 6: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/6.jpg)
6/94
Clipping Points
Given a point (x, y) and clipping window (xmin, ymin), (xmax, ymax), determine if the point should be drawn
(xmin,ymin)
(xmax,ymax)
xmin<=x1<=xmax Yes
ymin<=y1<=ymax Yes
(x1,y1)(x2,y2)
![Page 7: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/7.jpg)
7/94
Clipping Points
Given a point (x, y) and clipping window (xmin, ymin), (xmax, ymax), determine if the point should be drawn
(xmin,ymin)
(xmax,ymax)
xmin<=x2<=xmax Noymin<=y2<=ymax Yes
(x1,y1)(x2,y2)
![Page 8: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/8.jpg)
8/94
Clipping Lines
1P
2P
3P4P
5P
6P
7P
8P9P
10P
![Page 9: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/9.jpg)
9/94
Clipping Lines
5P
6̂P
7P
8P
9̂P
10P̂
![Page 10: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/10.jpg)
10/94
Clipping Lines
Given a line with end-points (x0, y0), (x1, y1)
and clipping window (xmin, ymin), (xmax, ymax),
determine if line should be drawn and clipped end-points of line to draw.
(x0, y0)
(x1, y1)
(xmin,ymin)
(xmax,ymax)
![Page 11: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/11.jpg)
11/94
Clipping Lines
1P
2P
3P4P
5P
6P
7P
8P9P
10P
![Page 12: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/12.jpg)
12/94
Clipping Lines – Simple Algorithm
If both end-points inside rectangle, draw line Otherwise,
intersect line with all edges of rectangle
clip that point and repeat test
![Page 13: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/13.jpg)
13/94
Clipping Lines – Simple Algorithm
),( 00 yx
),( minmin yx
),( maxmax yx
),( 11 yx
![Page 14: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/14.jpg)
14/94
Clipping Lines – Simple Algorithm
),( 00 yx
),( minmin yx
),( maxmax yx
),( 11 yx
![Page 15: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/15.jpg)
15/94
Clipping Lines – Simple Algorithm
)ˆ,ˆ( 00 yx
),( minmin yx
),( maxmax yx
),( 11 yx
![Page 16: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/16.jpg)
16/94
Clipping Lines – Simple Algorithm
)ˆ,ˆ( 00 yx
),( minmin yx
),( maxmax yx
),( 11 yx
![Page 17: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/17.jpg)
17/94
Clipping Lines – Simple Algorithm
)ˆ,ˆ( 00 yx
),( minmin yx
),( maxmax yx
),( 11 yx
![Page 18: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/18.jpg)
18/94
Clipping Lines – Simple Algorithm
)ˆ,ˆ( 00 yx
),( minmin yx
),( maxmax yx
),( 11 yx
![Page 19: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/19.jpg)
19/94
Clipping Lines – Simple Algorithm
),( 00 yx
),( minmin yx
),( maxmax yx
),( 11 yx
![Page 20: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/20.jpg)
20/94
Clipping Lines – Simple Algorithm
)ˆ,ˆ( 00 yx
),( minmin yx
),( maxmax yx
),( 11 yx
![Page 21: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/21.jpg)
21/94
Clipping Lines – Simple Algorithm
)ˆ,ˆ( 00 yx
),( minmin yx
),( maxmax yx
),( 11 yx
![Page 22: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/22.jpg)
22/94
Clipping Lines – Simple Algorithm
)ˆ,ˆ( 00 yx
),( minmin yx
),( maxmax yx
)ˆ,ˆ( 11 yx
![Page 23: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/23.jpg)
23/94
Clipping Lines – Simple Algorithm
)ˆ,ˆ( 00 yx
),( minmin yx
),( maxmax yx
)ˆ,ˆ( 11 yx
![Page 24: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/24.jpg)
24/94
Window Intersection
(x1, y1), (x2, y2) intersect with vertical edge at xright
yintersect = y1 + m(xright – x1)
where m=(y2-y1)/(x2-x1)
(x1, y1), (x2, y2) intersect with horizontal edge at ybottom
xintersect = x1 + (ybottom – y1)/m
where m=(y2-y1)/(x2-x1)
![Page 25: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/25.jpg)
25/94
Clipping Lines – Simple Algorithm
Lots of intersection tests makes algorithm expensive
Complicated tests to determine if intersecting rectangle
Is there a better way?
![Page 26: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/26.jpg)
26/94
Trivial Accepts
Big Optimization: trivial accepts/rejects How can we quickly decide whether line
segment is entirely inside window Answer: test both endpoints
![Page 27: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/27.jpg)
27/94
Trivial Accepts
Big Optimization: trivial accepts/rejects How can we quickly decide whether line
segment is entirely inside window Answer: test both endpoints
![Page 28: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/28.jpg)
28/94
Trivial Rejects
How can we know a line is outside of the window
Answer: both endpoints on wrong side of same edge, can trivially reject the line
![Page 29: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/29.jpg)
29/94
Trivial Rejects
How can we know a line is outside of the window
Answer: both endpoints on wrong side of same edge, can trivially reject the line
![Page 30: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/30.jpg)
30/94
Cohen-Sutherland Algorithm
Classify p0, p1 using region codes c0, c1
If , trivially reject If , trivially accept Otherwise reduce to trivial cases by splitting
into two segments
010 cc
010 cc
![Page 31: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/31.jpg)
31/94
Cohen-Sutherland Algorithm
Every end point is assigned to a four-digit binary value, i.e. Region code
Each bit position indicates whether the point is inside or outside of a specific window edge
bit 4 bit 3 bit 2 bit 1
leftrightbottomtop
![Page 32: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/32.jpg)
32/94
Cohen-Sutherland Algorithm
00000001
0101
1001 1000 1010
0010
01100100
![Page 33: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/33.jpg)
33/94
Cohen-Sutherland Algorithm
Classify p0, p1 using region codes c0, c1
If , trivially reject If , trivially accept Otherwise reduce to trivial cases by splitting
into two segments
010 cc
010 cc
![Page 34: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/34.jpg)
34/94
Cohen-Sutherland Algorithm
Classify p0, p1 using region codes c0, c1
If , trivially reject If , trivially accept Otherwise reduce to trivial cases by splitting
into two segments
010 cc
010 cc
![Page 35: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/35.jpg)
35/94
Cohen-Sutherland Algorithm
Classify p0, p1 using region codes c0, c1
If , trivially reject If , trivially accept Otherwise reduce to trivial cases by splitting
into two segments
010 cc
010 cc
00000001
0101
1001 1000 1010
0010
01100100
Line is outside the window! reject
![Page 36: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/36.jpg)
36/94
Cohen-Sutherland Algorithm
Classify p0, p1 using region codes c0, c1
If , trivially reject If , trivially accept Otherwise reduce to trivial cases by splitting
into two segments
010 cc
010 cc
00000001
0101
1001 1000 1010
0010
01100100
Line is inside the window! draw
![Page 37: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/37.jpg)
37/94
Cohen-Sutherland Algorithm
Classify p0, p1 using region codes c0, c1
If , trivially reject If , trivially accept Otherwise reduce to trivial cases by splitting
into two segments
010 cc
010 cc
00000001
0101
1001 1000 1010
0010
01100100
![Page 38: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/38.jpg)
38/94
Cohen-Sutherland Algorithm
00000001
0101
1001 1000 1010
0010
01100100
![Page 39: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/39.jpg)
39/94
Cohen-Sutherland Algorithm
00000001
0101
1001 1000 1010
0010
01100100
![Page 40: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/40.jpg)
40/94
Cohen-Sutherland Algorithm
00000001
0101
1001 1000 1010
0010
01100100
![Page 41: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/41.jpg)
41/94
Cohen-Sutherland Algorithm
00000001
0101
1001 1000 1010
0010
01100100
![Page 42: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/42.jpg)
42/94
Cohen-Sutherland Algorithm
00000001
0101
1001 1000 1010
0010
01100100
![Page 43: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/43.jpg)
43/94
Cohen-Sutherland Algorithm
00000001
0101
1001 1000 1010
0010
01100100
![Page 44: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/44.jpg)
44/94
Cohen-Sutherland Algorithm
00000001
0101
1001 1000 1010
0010
01100100
![Page 45: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/45.jpg)
45/94
Cohen-Sutherland Algorithm
00000001
0101
1001 1000 1010
0010
01100100
![Page 46: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/46.jpg)
46/94
Cohen-Sutherland Algorithm
00000001
0101
1001 1000 1010
0010
01100100
![Page 47: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/47.jpg)
47/94
Cohen-Sutherland Algorithm
00000001
0101
1001 1000 1010
0010
01100100
![Page 48: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/48.jpg)
48/94
Cohen-Sutherland Algorithm
00000001
0101
1001 1000 1010
0010
01100100
![Page 49: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/49.jpg)
49/94
Cohen-Sutherland Algorithm
00000001
0101
1001 1000 1010
0010
01100100
![Page 50: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/50.jpg)
50/94
Cohen-Sutherland Algorithm
00000001
0101
1001 1000 1010
0010
01100100
![Page 51: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/51.jpg)
51/94
Cohen-Sutherland Algorithm
00000001
0101
1001 1000 1010
0010
01100100
![Page 52: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/52.jpg)
52/94
Cohen-Sutherland Algorithm
00000001
0101
1001 1000 1010
0010
01100100
![Page 53: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/53.jpg)
53/94
Liang-Barsky Algorithm
Uses parametric form of line for clipping Lines are oriented
Classify lines as moving inside to out or outside to in
Don’t find actual intersection points
Find parameter values on line to draw
![Page 54: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/54.jpg)
54/94
Liang-Barsky Algorithm
Initialize interval to [tmin, tmax]=[0,1]
For each boundaryFind parametric intersection t with
boundary If moving in to out, tmax = min(tmax, t)
else tmin = max(tmin, t)
If tmin>tmax, reject line
![Page 55: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/55.jpg)
55/94
Intersecting Two Parametric Lines
),( 00 yx
),( 22 yx
),( 11 yx
),( 33 yx
![Page 56: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/56.jpg)
56/94
Intersecting Two Parametric Lines
),( 00 yx
),( 22 yx
),( 11 yxtxxxtx )()( 010 ),( 33 yx
tyyyty )()( 010
10 t
![Page 57: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/57.jpg)
57/94
Intersecting Two Parametric Lines
),( 00 yx
),( 22 yx
),( 11 yxtxxxtx )()( 010 ),( 33 yx
tyyyty )()( 010
0)0( xx 0)0( yy
1)1( xx 1)1( yy
![Page 58: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/58.jpg)
58/94
Intersecting Two Parametric Lines
),( 00 yx
),( 22 yx
),( 11 yx
sxxxtxxx )()( 232010
),( 33 yx
syyytyyy )()( 232010
![Page 59: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/59.jpg)
59/94
Intersecting Two Parametric Lines
),( 00 yx
),( 22 yx
),( 11 yx
02
02
3201
3201
yy
xx
s
t
yyyy
xxxx
),( 33 yx
![Page 60: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/60.jpg)
60/94
Intersecting Two Parametric Lines
),( 00 yx
),( 22 yx
),( 11 yx
02
02
3201
3201
yy
xx
s
t
yyyy
xxxx
),( 33 yx
Substitute t or s back into equation to find intersection
![Page 61: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/61.jpg)
61/94
Liang-Barsky: Classifying Lines
)(tp
)0(p
)1(p
outmoving01 xx
![Page 62: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/62.jpg)
62/94
Liang-Barsky: Classifying Lines
)(tp
)1(p
)0(p
inmoving10 xx
![Page 63: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/63.jpg)
63/94
Liang-Barsky: Classifying Lines
)(tp
)0(p
)1(p
inmoving01 xx
![Page 64: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/64.jpg)
64/94
Liang-Barsky: Classifying Lines
)(tp
)1(p
)0(p
outmoving10 xx
![Page 65: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/65.jpg)
65/94
Liang-Barsky: Classifying Lines
)(tp
)0(p
)1(p
inmoving01 yy
![Page 66: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/66.jpg)
66/94
Liang-Barsky: Classifying Lines
)(tp
)1(p
)0(p
outmoving10 yy
![Page 67: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/67.jpg)
67/94
Liang-Barsky: Classifying Lines
)(tp
)0(p
)1(p
outmoving01 yy
![Page 68: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/68.jpg)
68/94
Liang-Barsky: Classifying Lines
)(tp
)1(p
)0(p
inmoving10 yy
![Page 69: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/69.jpg)
69/94
Liang-Barsky Algorithm
)(tp
)0(p
)1(p
![Page 70: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/70.jpg)
70/94
Liang-Barsky Algorithm
)(tp
)0(p
)1(p
![Page 71: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/71.jpg)
71/94
Liang-Barsky Algorithm
)(tp
)0(p
)1(p
![Page 72: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/72.jpg)
72/94
Liang-Barsky Algorithm
)(tp
)0(p
)8(.p
![Page 73: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/73.jpg)
73/94
Liang-Barsky Algorithm
)0(p
)1(p
![Page 74: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/74.jpg)
74/94
Liang-Barsky Algorithm
)0(p
)1(p
![Page 75: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/75.jpg)
75/94
Liang-Barsky Algorithm
)0(p
)1(p
![Page 76: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/76.jpg)
76/94
Liang-Barsky Algorithm
)0(p
)1(p
)7.(p
![Page 77: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/77.jpg)
77/94
Liang-Barsky Algorithm
)1(p
)0(p
![Page 78: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/78.jpg)
78/94
Liang-Barsky Algorithm
)1(p
)2(.p
![Page 79: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/79.jpg)
79/94
Liang-Barsky Algorithm
)1(p
)0(p
![Page 80: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/80.jpg)
80/94
Liang-Barsky Algorithm
)1(p
)0(p
![Page 81: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/81.jpg)
81/94
Liang-Barsky Algorithm
)1(p
)1(.p
![Page 82: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/82.jpg)
82/94
Liang-Barsky Algorithm
)1(p
)1(.p
![Page 83: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/83.jpg)
83/94
Liang-Barsky Algorithm
)8(.p
)1(.p
![Page 84: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/84.jpg)
84/94
Liang-Barsky Algorithm
)8(.p
)1(.p
![Page 85: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/85.jpg)
85/94
Liang-Barsky Algorithm
)8(.p
)1(.p
![Page 86: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/86.jpg)
86/94
Liang-Barsky Algorithm
)1(p
)0(p
![Page 87: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/87.jpg)
87/94
Liang-Barsky Algorithm
)1(p
)0(p
![Page 88: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/88.jpg)
88/94
Liang-Barsky Algorithm
)1(p
)0(p
![Page 89: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/89.jpg)
89/94
Liang-Barsky Algorithm
)6(.p
)0(p
![Page 90: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/90.jpg)
90/94
Liang-Barsky Algorithm
)6(.p
)0(p
![Page 91: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/91.jpg)
91/94
Liang-Barsky Algorithm
)6(.p
)0(p
![Page 92: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/92.jpg)
92/94
Liang-Barsky Algorithm
)6(.p
)2(.p
![Page 93: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/93.jpg)
93/94
Comparison
Cohen-Sutherland Repeated clipping is expensive Best used when trivial acceptance and rejection is
possible for most lines Liang-Barsky
Computation of t-intersections is cheap (only one division)
Computation of (x,y) clip points is only done once
Algorithm doesn’t consider trivial accepts/rejects Best when many lines must be clipped
![Page 94: Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)](https://reader035.fdocuments.in/reader035/viewer/2022062713/56649ceb5503460f949b799e/html5/thumbnails/94.jpg)
94/94
Line Clipping – Considerations
Just clipping end-points does not produce the correct results inside the window
Must also update sum in midpoint algorithm
Clipping against non-rectangular polygons is also possible but seldom used