Type to enter a caption. Computer Graphics Week 5 Lecture 1
Polygon Clipping
Polygon Basics Convex Polygon Non Convex Polygon A line joining any two interior points lie completely inside the polygon A line joining any two interior points does not lie completely inside the polygon
Polygon Basics Postively Oriented Polygon: If the tour of vertices in the given order produces a counter clockwise circuit e.g. ABCDE → +vely oriented AEDCB → not +vely oriented
Mathematical defination of +ve orientation NOTE: If we tour along the edges of +vely oriented polygon our left hand would always point towards the inside of the polygon Let A(x1,y1) and B(x2,y2) be a directed line segment, Then a point P(x,y) will be to the left of line segment if C = (x2-x1)(y-y1) - (y2-y1)(x-x1) is +ve
Mathematical defination of Convex Polygon So if a point P(x,y) , that lies inside the polygon, is to the right of any edge , then the polygon is not Convex polygon (Given positive orientation)
Sutherland Hodgeman Algo For Clipping any polygon against a convex clipping window Successively , clips the polygon against the infinite edges of clipping window
S-H Algo Input : Vertices of polygon to be clipped (v1,v2, … , vn) Output : Produces a clipped polygon by introducing new vertices at places where the polygon gets clipped. Algo: The algo starts from the edge vn to v1, moves around the edges of polygon until it reaches back to vn. At each step , it examines the relationship between the polygon edge and the clipping boundary. Based on the relationship , adds zero,one or two vertices to the list of output vertices (that will define the clipped polygon) Explanation on board
SO, There could be 4 cases based on how polygon edge crosses the clipping boundary
Case: Both Vertices, of polygon edge (v1 and v2) , are inside the clipping boundary Output: Add v2 to output list Case 1
Case 2 Case: v1 is inside v2 is outside Output: Intersection point of polygon edge with the clipping boundary , i , is output Case 2
Case: Both v1 and v2 are outside Output: no output Case 3
Case: v1 is outside and v2 is inside Output: i and v2 Case 4
Example
Left Edge Clipping Input vertices : v1 to v8 Output vertices: i1,i2,v8,v7,v6,v5,v4,v3,v2
Bottom Edge Clipping Input vertices : i1,i2,v8,v7,v6,v5,v4,v3,v2 Output vertices: i2,v8,i3,i4,v6,v5,v4,v3,v2,i1
Right Edge Clipping Input vertices : i2,v8,i3,i4,v6,v5,v4,v3,v2,i1 Output vertices: i5,i6,v4,v3,v2,i1,i2,v8,i3,i4,v6
Top Edge Clipping Input vertices : i5,i6,v4,v3,v2,i1,i2,v8,i3,i4,v6 Output vertices: i7,i8,v2,i1,i2,v8,i3,i4,v6,i5,i6,v4
The End
Slide 1
Text
Text