Introduction to Polygons

Slides:



Advertisements
Similar presentations
Polygon Scan Conversion – 11b
Advertisements

SI23 Introduction to Computer Graphics
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 7 Scanline algorithm and polygon clipping Taku Komura.
Computer Graphics- SCC 342
Project-Impact/CSE/IITB/93 CG/Mod-2/SC/1 Basic Raster Graphics "Trifles make perfection, but perfection is no trifle" Michael Angelo ++ Topics Scan conversion.
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
Polygon Rasterization
Computer Graphics Scan Conversion Polygon Faculty of Physical and Basic Education Computer Science Dep Lecturer: Azhee W. MD.
Brute-Force Triangulation
Classes of Polygons Planar polygons Non-planar polygons Simple
Different types of Polygons Simple Convex Simple Concave Non-simple : self-intersecting With holes ConvexConcaveSelf-intersecting.
CPCS 391 Computer Graphics 1 Lecture 5: Polygon Filling
Implementation Dr. Amy Zhang. Reading 2  Hill, Chapters  Hill, Chapter 10.
CSCE 441: Computer Graphics Scan Conversion of Polygons
Graphics Programming: Polygon Filling
Scan Conversion II Revision 1.4 2/13/07 Copyright 2006, Dr. Zachary Wartell, UNCC, All Rights Reserved.
CS 454 Computer graphics Polygon Filling
Brute-Force Triangulation
TOPIC 4 PART III FILL AREA PRIMITIVES POLYGON FILL AREAS CGMB214: Introduction to Computer Graphics.
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
CGMB 314 Intro to Computer Graphics Fill Area Primitives.
1/24/20061 Fill-Area Algorithms and Functions. 1/24/20062 Learning Objectives OpenGL state variables Color and gray scale Color functions Point attributes.
Polygon Scan Conversion and Z-Buffering
9/7/06CS 6463: AT Computational Geometry1 CS 6463: AT Computational Geometry Fall 2006 Triangulations and Guarding Art Galleries Carola Wenk.
Triangulating a monotone polygon
Informationsteknologi Monday, November 26, 2007Computer Graphics - Class 121 Today’s class Drawing lines Bresenham’s algorithm Compositing Polygon filling.
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
College of Computer and Information Science, Northeastern UniversityMay 27, CS 4300 Computer Graphics Prof. Harriet Fell Fall 2012 Lecture 9 – September.
.. To transform something is to change it. In geometry, there are specific ways to describe how a figure is changed. The transformations you will learn.
Scan Conversion. Last step in the graphics pipeline Efficiency is a central issue Common primitives – Lines (done last class) – Polygons (fill polygons,
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 325 Introduction to Computer Graphics 03 / 22 / 2010 Instructor: Michael Eckmann.
Computer Graphics Filling. Filling Polygons So we can figure out how to draw lines and circles How do we go about drawing polygons? We use an incremental.
Lecture 15: Raster Graphics and Scan Conversion
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
Rasterization Overview Raster Display Device. Scan Conversion / Rasterization: converting vector graphics into raster graphics (determining pixels in.
Computer Graphics CC416 Week 14 Filling Algorithms.
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
Computer Graphics Lecture 08 Taqdees A. Siddiqi Computer Graphics Filled Area Primitives I Lecture 08 Taqdees A. Siddiqi
Computer Graphics Through OpenGL: From Theory to Experiments, Second Edition Chapter 14.
Computer Graphics I, Fall 2010 Scan conversion algorithms.
OUTPUT PRIMITIVES CEng 477 Computer Graphics METU, 2004.
CS552: Computer Graphics Lecture 16: Polygon Filling.
CMPS 3130/6130 Computational Geometry Spring 2017
Computer Graphics Filling.
Scan Conversion of Polygons
Computer Graphics CC416 Week 13 Clipping.
Polygons.
(c) 2002 University of Wisconsin, CS559
Computer Graphics Filled Area Primitives II Lecture 09 Taqdees A
Implementation III.
Fill Area Algorithms Jan
Polygon Filling Algorithms
Concepts, algorithms for clipping
Computer Graphics Filling & Color.
Prof. Harriet Fell Spring 2007 Lecture 9 – January 29, 2007
Computational Geometry Capter:1-2.1
Agenda Polygon Terminology Types of polygons Inside Test
Convex Sets & Concave Sets
Prepared by Narendra V G CSE MIT
Agenda Polygon Terminology Types of polygons Inside Test
I. The Problem of Molding
Prof. Harriet Fell Fall 2011 Lecture 9 – September 26, 2011
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
(c) 2002 University of Wisconsin, CS559
عَلَّمَهُ الْبَيَانَ He has taught him speech (and intelligence).
Rasterizing Polygons 2 Lecture 35 Mon, Nov 26, 2007.
Rasterizing Polygons Lecture 29 Wed, Dec 7, 2005.
Where We Stand At this point we know how to: Next thing:
Presentation transcript:

Introduction to Polygons Different types of Polygons Simple Convex Simple Concave Non-simple : self-intersecting With holes Convex Concave Self-intersecting

Introduction to Polygons Convex A region S is convex iff for any x1 and x2 in S, the straight line segment connecting x1 and x2 is also contained in S. The convex hull of an object S is the smallest H such that S

Scan Line Polygon Fill Algorithms A standard output primitive in general graphics package is a solid color or patterned polygon area: There are two basic approaches to filling on raster systems. Determine overlap Intervals for scan lines that cross that area. Start from a given interior point and paint outward from this point until we encounter the boundary The first approach is mostly used in general graphics packages, however second approach is used in applications having complex boundaries and interactive painting systems Xk+1,yk+1 Scan Line yk +1 Scan Line yk Xk , yk

Seed Fill Algorithm These algorithms assume that at least one pixel interior to a polygon or region is known Regions maybe interior or boundary defined Interior-defined region Interior-defined region

A Simple Seed Fill Algorithm Push the seed pixel onto the stack While the stack is not empty Pop a pixel from the stack Set the pixel to the required value For each of the 4 connected pixels Adjacent to the current pixel, check if it is a boundary pixel or if it has already been set to the required value. In either case ignore it. Otherwise push it onto the stack The algorithm can be implemented using 8 connected pixels It also works with holes in the polygons

Scan Line Polygon Fill Algorithm 10 14 18 24 Interior pixels along a scan line passing through a polygon area For each scan line crossing a polygon are then sorted from left to right, and the corresponding frame buffer positions between each intersection pair are set to the specified color. These intersection points are then sorted from left to right , and the corresponding frame buffer positions between each intersection pair are set to specified color

Scan Line Polygon Fill Algorithm In the given example ( previous slide) , four pixel intersections define stretches from x=10 to x=14 and x=18 to x=24 Some scan-Line intersections at polygon vertices require special handling: A scan Line passing through a vertex intersects two polygon edges at that position, adding two points to the list of intersections for the scan Line In the given example , scan Line y intersects five polygon edges and the scan Line y‘ intersects 4 edges although it also passes through a vertex y‘ correctly identifies internal pixel spans ,but need some extra processing

Scan line Polygon Fill Algorithm One way to resolve this is also to shorten some polygon edges to split those vertices that should be counted as one intersection When the end point y coordinates of the two edges are increasing , the y value of the upper endpoint for the current edge is decreased by 1 When the endpoint y values are monotonically decreasing, we decrease the y coordinate of the upper endpoint of the edge following the current edge

Scan Line Polygon Fill Algorithm (b) Adjusting endpoint values for a polygon, as we process edges in order around the polygon perimeter. The edge currently being processed is indicated as a solid like. In (a), the y coordinate of the upper endpoint of the current edge id decreased by 1. In (b), the y coordinate of the upper end point of the next edge is decreased by 1

Scan Line Polygon Fill Algorithm The topological difference between scan Line y and scan Line y'

The topological difference between scan line y and scan line y’ is … For Scan line y, the two intersecting edges sharing a vertex are on opposite sides of the scan line …! But for scan line y’, the two intersecting edges are both above the scan line Thu, the vertices that require additional processing are those that have connecting edges on opposite sides of scan line. We can identify these vertices by tracing around the polygon boundary either in clock-wise or anti-clockwise order and observing the relative changes in vertex y coordinates as we move from one edge to the next. If the endpoint y values of two consecutive edges monotonically increase or decrease, we need to count the middle vertex as a single intersection point for any scan line passing through that vertex.

Otherwise, the shared vertex represents a local extremum (min. or max Otherwise, the shared vertex represents a local extremum (min. or max.) on the polygon boundary, and the two edge intersections with the scan line passing through that vertex can be added to the intersection list Figure 3-36 Intersection points along the scan lines that intersect polygon vertices. Scan line y generates an odd number of intersections, but scan line y generates an even number of intersections that can be paired to identify correctly the interior pixel spans.

The scan conversion algorithm works as follows Intersect each scanline with all edges Sort intersections in x Calculate parity of intersections to determine in/out Fill the “in” pixels Special cases to be handled: Horizontal edges should be excluded For vertices lying on scanlines, count twice for a change in slope. Shorten edge by one scanline for no change in slope Coherence between scanlines tells us that Edges that intersect scanline y are likely to intersect y + 1 X changes predictably from scanline y to y + 1

y_upper: last scanline to consider We have 2 data structures: Edge Table and Active Edge Table Traverse Edges to construct an Edge Table Eliminate horizontal edges Add edge to linked-list for the scan line corresponding to the lower vertex. Store the following: y_upper: last scanline to consider x_lower: starting x coordinate for edge 1/m: for incrementing x; compute Construct Active Edge Table during scan conversion. AEL is a linked list of active edges on the current scanline, y. Each active edge line has the following information x_lower: edge’s intersection with current y 1/m: x increment The active edges are kept sorted by x

Algorithm Set y to the smallest y coordinate that has an entry in the ET; i.e, y for the first nonempty bucket. Initialize the AET to be empty. Repeat until the AET and ET are empty: 3.1 Move from ET bucket y to the AET those edges whose y_min = y (entering edges). 3.2 Remove from the AET those entries for which y = y_max (edges not involved in the next scanline), the sort the AET on x (made easier because ET is presorted). 3.3 Fill in desired pixel values on scanline y by using pairs of x coordinates from AET. 3.4 Increment y by 1 (to the coordinate of the next scanline). 3.5 For each nonvertical edge remaining in the AET, update x for the new y. Extensions: Multiple overlapping polygons – priorities Color, patterns Z for visibility