Computer Graphics CC416 Week 13 Clipping.

Slides:



Advertisements
Similar presentations
Computer Graphics 4: Viewing In 2D
Advertisements

Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 7 Scanline algorithm and polygon clipping Taku Komura.
Rezanje črt in poligonov. World window & viewport window viewport screen window world window.
Computer Graphics CLIPPING.
Objectives Define Clipping Various clipping methods. Line clipping methods.
Line clipping: Line clipping algorithm is method of eliminate lines of outside area of the object,so outside of object viewing is Removed. Typically, any.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Course Website: Computer Graphics 4: Viewing In 2D.
Computer Graphics : Clipping
Computer Graphics Viewing.
Viewing & Clipping In 2D. 2 of 44 Contents Windowing Concepts Clipping –Introduction –Brute Force –Cohen-Sutherland Clipping Algorithm Area Clipping –Sutherland-Hodgman.
CMPE 466 COMPUTER GRAPHICS Chapter 8 2D Viewing Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth Edition by Donald Hearn,
2D Viewing and Projection
2 D viewing Prepared by Elizabeth Isaac DCS, RSET.
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphics Two Dimensional Viewing Dr. Eng. Farag Elnagahy
Graphics Pipeline Clipping CMSC 435/634. Graphics Pipeline Object-order approach to rendering Sequence of operations – Vertex processing – Transforms.
1 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD3107 University of Palestine.
2-Dimension Viewing and Clipping
CS 376 Introduction to Computer Graphics 02 / 12 / 2007 Instructor: Michael Eckmann.
Two-Dimensional Viewing
Clipping: Clipping is a process of dividing an object into visible and invisible positions and displaying the visible portion and discarding the invisible.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
Windows, Viewports, and Clipping
Unit – IV 2D Viewing. 2 of 30 Contents Windowing Concepts The viewing pipeline viewing coordinate reference frame, window to view-port coordinate transformation,
EEL Introduction to Computer Graphics
2D Viewing.
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 3 1.
A.Aruna/Assistant Professor/SNSCE
Computer Graphics Lecture 08 Taqdees A. Siddiqi Computer Graphics Filled Area Primitives I Lecture 08 Taqdees A. Siddiqi
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.
Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal.
CS552: Computer Graphics Lecture 16: Polygon Filling.
Clipping.
Two-Dimensional Viewing Hearn & Baker Chapter 6
Computer Graphics Lecture 14 CLIPPING I Taqdees A. Siddiqi
Computer Graphic 2 D Viewing.
Computer Graphics Clipping.
Introduction to Computer Graphics with WebGL
Transformations contd.
CS 551 / 645: Introductory Computer Graphics
Concepts, Algorithms for line clipping
Two-Dimensional Viewing
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Computer Graphics Viewing
2D Viewing & Clipping 한신대 류승택
Fill Area Algorithms Jan
Concepts, algorithms for clipping
3D Clipping.
Graphics Pipeline Clipping
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Chapter 7 2D Clipping.
WINDOWING AND CLIPPING
o عَلَّمَهُ الْبَيَانَ
Computer Graphics : Viewing In 2D
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
WINDOWING AND CLIPPING
Lecture 13 Clipping & Scan Conversion
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Two Dimensional Viewing and Clipping.
Segment Clipping Simple algorithm. For each segment compute the intersection with the four sides of the rectangle, and then determine which sub-segment.
Clipping Clipping Sutherland-Hodgman Clipping
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.
Type to enter a caption. Computer Graphics Week 5 Lecture 1.
Clipping University of British Columbia CPSC 314 Computer Graphics
COMPUTER GRAPHICS Clipping
Presentation transcript:

Computer Graphics CC416 Week 13 Clipping

Introduction Any procedure that identifies those portions of a picture that are either inside or outside of a specified region of space is referred to as a clipping algorithm, or simply clipping The region against which an object is to be clipped is called a clip window.

Clipping can be used in identifying visible surfaces in 3D views displaying a multi-window environment drawing and painting operations that allow parts of a picture to be selected for copying, moving, erasing, or duplicating

The clip window can be a general polygon or it can even have curved boundaries

Clipping Algorithms can be applied in world coordinates, so that only the contents of the window interior are mapped to device coordinates the complete world-coordinate picture can be mapped first to device coordinates, or normalized device coordinates, then clipped against the viewport boundaries

Viewport clipping, on the other hand, can reduce calculations Types of clipping Point Clipping Line Clipping (straight-line segments) Area Clipping (polygons) Curve Clipping Text Clipping

Point Clipping A point is considered if the following inequalities are satisfied where the edges of the clip window are

Line Clipping

A line clipping procedure involves several parts Determine whether the line lies completely inside the clipping window If not, determine whether it lies completely outside the window If not, perform intersection calculations with one or more clipping boundaries

Cohen Sutherland line clipping Each region code identifies the location of the point relative to the boundaries of the clipping rectangle bit 1: left bit 2: right bit 3: below bit 4: above

A value of 1 in any bit position indicates that the point is in that relative position; otherwise, the bit position is set to 0 If a point is within the clipping rectangle, the region code is 0000. A point that is below and to the left of the rectangle has a region code of 0101.

Bit values in the region code are determined by comparing endpoint coordinate values (x, y) to the clip boundaries Bit 1 is set to 1 if x < xwmin The other three bit values can be determined using similar comparisons

Determine which lines are completely inside the clip window and which are clearly outside Any lines that are completely contained within the window boundaries have a region code of 0000 for both endpoints Any lines that have a 1 in the same bit position in the region codes for each endpoint are completely outside the clipping rectangle

Lines that cannot be identified as completely inside or completely outside a clip window by these tests are checked for intersection with the window boundaries. Intersection points with a clipping boundary can be calculated using the slope-intercept form of the line equation

For a line with endpoint coordinates (x1,y1) and (x2, y2) the coordinate of the intersection point with a vertical boundary can be obtained with the calculation where the x value is set either to xwmin or to xwmax, and the slope of the line is calculated as m = (y2 – y1)/(x2 – x1)

The intersection with a horizontal boundary, the x coordinate can be calculated as with y set either to ywmin, or to ywmax.

Example check P1 against the left, right, and bottom boundaries in turn this point is below the clipping rectangle find the intersection point P1’ with the bottom boundary and discard the line section from P1 to P1’ The line now has been reduced to the section from P1’ to P2

Since P2 is outside the clip window, we check this endpoint against the boundaries It is to the left of the window Intersection point P2’ is calculated this point is above the window, so the final intersection calculation yields P2’’ the line from P1’ to P2’’ is saved

P3 is to the left of the clipping rectangle, so determine the intersection P3’ Eliminate the line section from P3 to P3’ By checking region codes for the line section from P3’ to P4, we find that the remainder of the line is below the clip window and can be discarded also.

Polygon Clipping We can use line clipping algorithms to achieve polygon clipping What we really want to display is a bounded area after clipping The output of a polygon clipper should be a sequence of vertices that defines the clipped polygon boundaries closed areas are then scanned with the appropriate area fill

Sutherland-Hodgeman Polygon clipping Process the polygon boundary as a whole against each window edge This could be accomplished by processing all polygon vertices against each clip rectangle boundary in turn Beginning with the initial set of polygon vertices, we could first clip the polygon against the left rectangle boundary to produce a new sequence of vertices. The new set of vertices could then be successively passed to a right boundary clipper, a bottom boundary clipper, and a top boundary clipper

There are four possible cases when processing vertices in sequence around the perimeter of a polygon. If the first vertex is outside the window boundary and the second vertex is inside, both the intersection point of the polygon edge with the window boundary and the second vertex are added to the output vertex list

If both input vertices are inside the window boundary, only the second vertex is added to the output vertex list If the first vertex is inside the window boundary and the second vertex is outside, only the edge intersection with the window boundary is added to the output vertex list If both input vertices are outside the window boundary, nothing is added to the output list

Once all vertices have been processed for one clip window boundary, the output list of vertices is clipped against the next window boundary

Example Process the area against left boundary Vertices 1 and 2 are outside the boundary, so they are not saved Vertex 3 is inside, so we save the intersection and vertex 3 Vertices 4 and 5 are inside, both are saved Vertex 5 is inside and vertex 6 is outside, vertex 5 and the intersection are saved Vertices 6 and 1 are outside, so they are not saved

Disadvantages Convex polygons are correctly clipped by the Sutherland-Hodgeman algorithm concave polygons may be displayed with unwanted lines This occurs when the clipped polygon should have two or more separate sections. Because there is only one output vertex list, the last vertex in the list is always joined to the first vertex Other algorithms can be used to solve this problem