+ All Categories
Home > Documents > 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

Date post: 17-Dec-2015
Category:
Upload: elvin-martin
View: 222 times
Download: 1 times
Share this document with a friend
21
168 471 Computer Graphics, KKU. Lec ture 8 1 Clipping on a Raster Display
Transcript
Page 1: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

1

Clipping on a Raster Display

Page 2: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

2

Approaches to Clipping

Page 3: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

3

Analytical Clipping

Page 4: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

4

Clipping Lines Against Rectangles

Page 5: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

5

Clipping Rules

Page 6: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

6

Computing Intersections

Page 7: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

7

- Cohen Sutherland Algorithm

Page 8: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

8

Outcodes

Page 9: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

9

Outcode Computation

typedef unsigned int outcode; enum {TOP = 0x1, BOTTOM = 0x2, RIGHT = 0x4, LEFT = 0x8}

outcode CompOutCode( double x, double y, double xmin, double xmax, double ymin, double ymax){ outcode code = 0; if ( y > ymax ) code |= TOP; else if ( y < ymin ) code |= BOTTOM; if ( x > xmax ) code |= RIGHT; else if ( x < xmin ) code |= LEFT; return code;

}

Page 10: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

10

- Cohen Sutherland Procedures

Page 11: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

11

- Cohen Sutherland Procedures

Page 12: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

12

- Cohen Sutherland Algorithm

Page 13: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

13

- Cohen Sutherland Algorithm (cont.)

Page 14: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

14

- Cohen Sutherland Procedures

Page 15: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

15

Parametric Line-Clipping Algorithm

0 1 0

0 1 0

0

1 0

[ ( ) ] 0

[ ( ) ] 0

[ ] [ ] 0

[ ]

( )

i Ei

i Ei

i Ei i

i Ei

i

N P t P

N P P P t P

N P P N P P t

N P Pt

N D

whereD P P

• 1978IntroducedbyCyrudandBeck i n• EEEEEEEEEEE EE EEEEEE EE EEEEE EEE EEEEEE• Essentially find the parameter t from P(t) = P

0 + (P

1-P0)

Page 16: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

16

- Parametric Line Clipping Algorith m (cont.)

• EEE EE EEEEEEEEEE EE EE EEEEEEEEEEEE E, ( ntering) and PL (potentially leaving) on the basis of the angle between P0

P1

and Ni

• E EEEEE EEE EE EE EL for each intersection• EEEEEE EEE EEEE EEEE EEE EEEE EEE E EEEE EE EE EEE EEEEEEE EL

• If tE E> L EEEE EEEEEEEEE EEEEEEEE,

0 ( 90)

0 ( 90)i

i

N D PE angle

N D PL angle

Page 17: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

17

- Parametric Line Clipping Algorith m (cont.)

Page 18: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

18

- Cyrus Beck Algorithm (Pseudocode)

Page 19: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

19

Clipping Circles and Ellipses

• Firstly, do a trivial accept/reject test by intersec ting the circle’s/elleipse’s extent with the clip re

ctengle.• If intersection occurs, divide it into and do the tr

ivial accept/reject test for each.• If scan conversion is fast or if the circle is not to

- - o large, scissoring on a pixel by pixel basis woul d be more efficient.

Page 20: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

20

Clipping Polygons

Example of polygon clipping, (a) Multiple components. (b) Simple convex case. (c) Concave case.

Page 21: 168 471 Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.

168 471 Computer Graphics, KKU. Lecture 8

21

Clipping Polygons (cont.)

Polygon clipping, edge by edge. (a) Before clipping. (b) Clip on right. (c) Clip on bottom. (d) Clip on left. (e) Clip on top; polygon is fully clipped


Recommended