Presentation is loading. Please wait.

Presentation is loading. Please wait.

Clipping Polygon Clipping Polygon : Area primitive

Similar presentations


Presentation on theme: "Clipping Polygon Clipping Polygon : Area primitive"— Presentation transcript:

1 Clipping Polygon Clipping Polygon : Area primitive
Simple Polygon: Planar set of ordered points No line crossings No holes V3 V4 V1 V2 Simple Polygon Line Crossing Hole

2 Clipping Polygon Clipping Polygon : Area primitive Non-Convex Polygon

3 Clipping Polygon Clipping Sutherland-Hodgman Window must be convex
Polygon to be clipped can be convex or non-convex Polygon Polygon Window

4 Clipping Polygon Clipping Sutherland-Hodgman Window must be convex
Polygon to be clipped can be convex or non-convex

5 Clipping Polygon Clipping Sutherland-Hodgman

6 Clipping Polygon Clipping Sutherland-Hodgman Approach
Polygon to be clipped is given as v1, v2, …, vn Polygon edge is a pair [vi, vi+1] Process all polygon edges in succession against a window edge polygon (v1, v2, …, vn) polygon (w1, w2, …, wm) Repeat on resulting polygon with next window edge

7 Clipping Polygon Clipping Sutherland-Hodgman Approach Four Cases
s = vi is the polygon edge starting vertex p = vi+1 is the polygon edge ending vertex i is a polygon-edge/window-edge intersection point wj is the next polygon vertex to be output

8 Clipping Polygon Clipping Sutherland-Hodgman Approach
Case 1: Polygon edge is entirely inside the window edge Inside Outside s p is next vertex of resulting polygon p wj and j+1 j p Output

9 Clipping Polygon Clipping Sutherland-Hodgman Approach
Case 2: Polygon edge crosses window edge going out Inside Outside Intersection point i is next vertex of resulting polygon i wj and j+1 j p s i Output

10 Clipping Polygon Clipping Sutherland-Hodgman Approach
Case 3: Polygon edge is entirely outside the window edge Inside Outside p No output s

11 Clipping Polygon Clipping Sutherland-Hodgman Approach
Case 4: Polygon edge crosses window edge going in Inside Outside Output s p i Intersection point i and p are next two vertices of resulting polygon i wj and p wj+1 and j+2 j

12 Clipping Polygon Clipping Sutherland-Hodgman Example s5 s4 s3 s2 s1
Window s1

13 Clipping Polygon Clipping Sutherland-Hodgman Example s5 s4 i2 i1 s3 s2

14 Clipping Polygon Clipping Sutherland-Hodgman Example t4 t3 t2 t1 t5

15 Clipping Polygon Clipping Sutherland-Hodgman Example u3 u2 u1 u5 u4

16 Clipping Polygon Clipping Sutherland-Hodgman Example v2 i3 v1 i6 v5 i5

17 Clipping Polygon Clipping Sutherland-Hodgman Example w1 w6 w5 w4 w3 w2

18 Polygon Scan Conversion
Polygon Filling Consider first triangle

19 Polygon Scan Conversion
Polygon Filling Consider first triangle Color all pixels inside triangle Inside (containment) test

20 Polygon Scan Conversion
Polygon Filling Triangle Use horizontal spans. Process horizontal spans in scan-line order. For the next spans use edge slopes XL XR

21 Polygon Scan Conversion
Polygon Filling Polygon How do we decide what parts of the span should be filled ?

22 Polygon Scan Conversion
Polygon Filling Polygon How do we decide what parts of the span should be filled ? Parity check if odd fill if even don’t fill

23 Polygon Scan Conversion
Polygon Filling Polygon What happens here?

24 Polygon Scan Conversion
Polygon Filling Polygon What happens here?

25 Polygon Scan Conversion
Polygon Filling Polygon Recursive seed filling

26

27 Geometrical Transformation
Translation P ( x , y ) P ' ( x ' , y ' ) P’ x ' = x + t ; y ' = y + t x y P T P ' = P + T P = [ x , y ]; T = [ t , t ] x y

28 Geometrical Transformation
Scaling P ( x , y ) P ' ( x ' , y ' ) x ' = s x ; y ' = s y x y é s ù x [ x ' , y ' ] = [ x , y ] ê ú s ë û y P ' = P . S

29 Geometrical Transformation
Scaling P ( x , y ) P ' ( x ' , y ' ) x ' = s x ; y ' = s y x y é s ù [ x ' ' x , y ] = [ x , y ] ê ú s ë û y P ' = P . S s = s : uniform scaling x y s s : differenti al scaling x y

30 Geometrical Transformation
Rotation P ( x , y ) P ' ( x ' , y ' ) x = r cos( φ ); y = r sin( φ ) x ' = r cos( φ + θ ) P’ y ' = r sin( φ + θ ) q P ' = - f x x cos( θ ) y sin( θ ) y ' = x sin( θ ) + y cos( θ ) é cos( θ ) sin( θ ) ù [ x ' , y ' ] = [ x , y ] ê ú - ë sin( θ ) cos( θ ) û P ' = P . R θ

31 Geometrical Transformation
General 2x2 Matrix X X ' X ' = X . T é a b ù [ x ' , y ' ] = [ x , y ] = [( ax + cy ), ( bx + dy )] ê ú ë c d û If a = d = 1 and b = c = 0 T = Identity Matrix X’ = X

32 Geometrical Transformation
General 2x2 Matrix y If b = c = 0 X’ = [ax, dy] : Scaling If b = c = 0 and a = -1, d = 1 X’ = [-x, y] : Reflection P’ P x

33 Geometrical Transformation
General 2x2 Matrix é 1 ù Shearing in X [ x ' , y ' ] = [ x , y ] = [ x + cy , y ] ê ú ë c 1 û

34 Geometrical Transformation
General 2x2 Matrix é 1 b ù Shearing in Y [ x ' , y ' ] = [ x , y ] = [ x , bx + y ] ê ú ë 1 û

35 Geometrical Transformation
Homogenous Coordinates Scale/Rotate/Reflect/Shear: X’ = XT Translate: X’ = X + T P = [ x , y ] P = [ x , y , w ] h Multiple values for the same point e.g., (2, 3, 6) and (4, 6, 12) are same points

36 Geometrical Transformation
Homogenous Coordinates w (x, y,w) (x/w, y/w,1) w=1 x y

37 Geometrical Transformation
Homogenous Coordinates Unifying representation for transformation Transformation matrix from 2x2 to 3x3 X X ' X ' = X . T é a b ù ê ú [ x ' , y ' , w ] = [ x , y , 1 ] c d ê ú ë ê l m 1 ú û = [( ax + cy + l ), ( bx + dy + m ), 1 ]

38 Geometrical Transformation
Homogenous Coordinates Translation é 1 ù ê ú T = 1 ê ú ê l m 1 ú ë û X ' = XT [ x ' , y ' ] = [ x + l , y + m ]

39 Geometrical Transformation
Homogenous Coordinates Scaling/Rotation/Shear é a b ù ê ú T = c d ê ú ë ê 1 ú û

40 Geometrical Transformation
Homogenous Coordinates Successive translations: T1 = (l1, m1), T2 = (l2, m2) After T1 After T1 and T2 Successive translations are additive

41 Geometrical Transformation
Homogenous Coordinates Successive scaling: S1 = (sx1, sy1), S2 = (sx2, sy2) After S1 After S1 and S2 Successive scaling is multiplicative

42 Geometrical Transformation
Homogenous Coordinates Successive rotations: R(q), R(f) After R(q) After R(q) and R(f) Successive rotations are additive

43 Geometrical Transformation
Composition of transformation Rotation about arbitrary point y Rotation about origin is known Translate such that P becomes O Rotate (about O) Translate back to P P O x

44 Geometrical Transformation
Composition of transformation Rotation about arbitrary point y Rotation about origin is known Translate such that P becomes O P O x

45 Geometrical Transformation
Composition of transformation Rotation about arbitrary point y Rotation about origin is known Rotate about O O x

46 Geometrical Transformation
Composition of transformation Rotation about arbitrary point y Rotation about origin is known Translate back to P P O x

47 Geometrical Transformation
Composition of transformation Composite transformation

48 Geometrical Transformation
Composition of transformation Reflection about an arbitrary line B y C A O x

49 Geometrical Transformation
Composition of transformation Reflection about an arbitrary line y B Translation C A O x

50 Geometrical Transformation
Composition of transformation Reflection about an arbitrary line y B Rotation A C O x

51 Geometrical Transformation
Composition of transformation Reflection about an arbitrary line y Reflection O x A C B

52 Geometrical Transformation
Composition of transformation Reflection about an arbitrary line y Rotation C O A x B

53 Geometrical Transformation
Composition of transformation Reflection about an arbitrary line y Translation C A O x B

54 Geometrical Transformation
Composition of transformation Given T1 and T2 In general,

55 Geometrical Transformation
Rigid Transformations Square remains square Preserves length and angles Sequence of rotations and translations é r r ù 11 12 ê ú T = r r ê 21 22 ú ê ë l m 1 ú û

56 Geometrical Transformation
Affine Transformations Preserves parallelism Sequence of rotations, translations, scaling and shear Linear transformation is when no translation

57 Geometrical Transformation
General Transformation 3x3 matrix


Download ppt "Clipping Polygon Clipping Polygon : Area primitive"

Similar presentations


Ads by Google