Polygons.

Slides:



Advertisements
Similar presentations
Computer Graphics- SCC 342
Advertisements

COMP 175 | COMPUTER GRAPHICS Remco Chang1/6103b – Shapes Lecture 03b: Shapes COMP 175: Computer Graphics February 3, 2015.
CHAPTER 3 2D GRAPHICS ALGORITHMS
CMPE 466 COMPUTER GRAPHICS
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
CP411 polygon Lecture 6 1. Scan conversion algorithm for circle 2. Draw polygons 3. Antialiasing.
Computer Graphics Scan Conversion Polygon Faculty of Physical and Basic Education Computer Science Dep Lecturer: Azhee W. MD.
 3.3: Angles of Polygons. What is a Polygon?  A polygon is a closed plane figure made up of three or more line segments that intersect only at their.
Chapter 6 Polygons. A polygon is a closed plane figure formed by three or more segments that intersect only at their endpoints. PolygonsNot Polygons.
Classes of Polygons Planar polygons Non-planar polygons Simple
2IV60 Computer graphics Graphics primitives and attributes Jack van Wijk TU/e.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
3-5 The Polygon Angle-Sum Theorems
CS 450: Computer Graphics OVERVIEW OF POLYGONS
Different types of Polygons Simple Convex Simple Concave Non-simple : self-intersecting With holes ConvexConcaveSelf-intersecting.
CSCE 441: Computer Graphics Scan Conversion of Polygons
Drawing Geometric Objects
Graphics Programming: Polygon Filling
1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D.
1 CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai.
CS 454 Computer graphics Polygon Filling
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.
March Shape Drawing Algorithms Shmuel Wimer Bar Ilan Univ., Engineering Faculty.
GRAPHICS OUTPUT PRIMITIVES CA 302 Computer Graphics and Visual Programming Aydın Öztürk
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
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.
Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A.
Vertex – A point at which two or more edges meet Edge – A line segment at which two faces intersect Face – A flat surface Vertices, Edges, Faces.
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
Polygons A Polygon is a closed plane figure formed by 3 or more segments Each segment intersects exactly 2 other segments only at their endpoints. No.
Computer Graphics Basic 3D Geometry CO2409 Computer Graphics Week 5-1.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner Rasterization.
Drill 1)If two angles of a triangle have a sum of 85 degrees find the third angle. 2) The three angles of a triangle are 2x, 3x, and 2x + 40 find each.
1 11. Polygons Polygons 2D polygons ( 다각형 ) –Polygon sides are all straight lines lying in the same plane 3D polyhedra ( 다면체 )  chap. 12 –Polyhedra.
12.1 Exploring Solids.
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.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
CLASSIFYING POLYGONS UNIT 1 LESSON 6. Classifying Polygons In geometry, a figure that lies in a plane is called a plane figure. A polygon is a closed.
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 15 Creating 3D Models.
Section 12-1 Exploring Solids. Polyhedron Three dimensional closed figure formed by joining three or more polygons at their side. Plural: polyhedra.
11 Chapter Introductory Geometry
Sum of Interior Angles and Exterior Angles. Sum of Interior Angles of a Polygon 180(n-2) Where n is the number of sides Interior angles are the angles.
Computer Graphics CC416 Week 14 Filling Algorithms.
Computer Graphics Lecture 08 Taqdees A. Siddiqi Computer Graphics Filled Area Primitives I Lecture 08 Taqdees A. Siddiqi
Polygons 1 What is the difference between concave and convex?
Chapter- 3 & Unit-2 Graphics PRIMITIVES 1. Objectives Introduction to Primitives Points & Lines Line Drawing Algorithms Digital Differential Analyzer.
Graphics PRIMITIVES Chapter- 3 & Unit-2.
Sum of Interior and Exterior Angles in Polygons
Computer Graphics Filling.
Scan Conversion of Polygons
Introduction to Polygons
Polygons.
Computer Graphics Filled Area Primitives II Lecture 09 Taqdees A
Fill Area Algorithms Jan
Polygon Filling Algorithms
Agenda Polygon Terminology Types of polygons Inside Test
11 Chapter Introductory Geometry
CSE 411 Computer Graphics Lecture #3 Graphics Output Primitives
Prepared by Narendra V G CSE MIT
Agenda Polygon Terminology Types of polygons Inside Test
ویژگیهای مبناهای گرافیکی
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Introduction to Meshes
Primitive Drawing Algorithm
Primitive Drawing Algorithm
Introduction to Meshes
Presentation transcript:

Polygons

Polygons

Triangle Meshes

Polygon Tables Vertex Table Edge Table Surface Table v1: x1, y1, z1 E1: v1, v2 E2: v2, v3 E3: x3, v1 E4: v3, v4 E5: v4, v5 E5: v5, v1 Surface Table S1: E1, E2, E3 S2: E3, E4, E5, E6

Front and Back Faces Any point (x, y, z) is: on the plane: A.x + B.y + C.z + D = 0 behind the plane: A.x + B.y + C.z + D < 0 in front of the plane: A.x + B.y + C.z + D > 0 y in front of (outside) the plane x front face behind (inside) the plane z

Front and Back Faces A.x + B.y + C.z + D = 0 N = (v2-v1) x (v3-v1) N.P = -D y Normal vector N=(A, B, C) v3 v2 x v1 z

all interior angles are Polygons convex all interior angles are <1800 concave at least one angle is >1800

Identifying Concave Polygons Method 1 if some vertices are on one side and some on the other side of an extension line, then concave v4 E3 E5 v3 E2 v1 v2 E1

Splitting Concave Polygons Rotational Method Shift polygon so that each vertex vk in turn is at the coordinate origin Rotate polygon about the origin in clockwise direction so that next vertex vk+1 is on the x axis If vk+1 is below the x-axis, polygon is concave Split polygon along x-axis y v1 v2 v3 v4 v5 x

Splitting Concave Polygons Rotational Method Shift polygon so that each vertex vk in turn is at the coordinate origin Rotate polygon about the origin in clockwise direction so that next vertex vk+1 is on the x axis If vk+1 is below the x-axis, polygon is concave Split polygon along x-axis v1 v2 v3 v4 v5 y x

Identifying Concave Polygons Method 2 if cross product of adjacent vector pairs is <0, then concave v4 E3 E5 v3 E2 v1 v2 E1

Splitting Concave Polygons Vector Method Find the cross products of edge vectors (Ek x Ek+1) If z component is negative then split polygon along the line of the first edge vector in the cross product pair Then find the intersection of the line with other edges of the polygon E4 v5 v4 E3 E5 v3 E2 v1 v2 E1

Splitting Convex Polygons into Triangles

Polygon Filling: Inside-Outside Test Odd-Even Test Draw a line from any point P to a point outside the closed polyline If the number of line-segment crossings is: odd => P is an interior point even => P is an exterior point

Polygon Filling: Scan-Line Algorithm Find intersection of polygon boundaries with screen scan lines (solving the pair of simultaneous linear equations where scanline is y, which is a constant) Apply fill-color to scan line sections that lie within the fill region (use odd-even rule)

Polygon Filling: Scan-Line Algorithm Monotonically increasing/decreasing

Polygon Filling: Scan-Line Algorithm Incremental calculation of intersection points yk+1 – yk =1 m = 1/ (xk+1 – xk ) xk+1 = xk + 1/m (xk+1, yk+1) yk+1 yk (xk, yk) xk xk+1

Polygon Filling: Boundary-Fill Algorithm 4-connected 8-connected

Polygon Filling: Boundary-Fill Algorithm void boundaryFill4 (int x, int y, int fillColor, int borderColor) { int interiorColor; /* Set current color to fillColor, then perform following oprations. */ getPixel (x, y, interiorColor); if ((interiorColor != borderColor) && (interiorColor != fillColor)) setPixel (x, y); // Set pixel color to fillColor boundaryFill4 (x + 1, y , fillColor, borderColor); boundaryFill4 (x - 1, y , fillColor, borderColor); boundaryFill4 (x , y + 1, fillColor, borderColor); boundaryFill4 (x , y - 1, fillColor, borderColor) }

Polygon Filling: Boundary-Fill Algorithm void boundaryFill4 (int x, int y, int fillColor, int borderColor) { int interiorColor; /* Set current color to fillColor, then perform following oprations. */ getPixel (x, y, interiorColor); if ((interiorColor != borderColor) && (interiorColor != fillColor)) setPixel (x, y); // Set pixel color to fillColor boundaryFill4 (x + 1, y , fillColor, borderColor); boundaryFill4 (x - 1, y , fillColor, borderColor); boundaryFill4 (x , y + 1, fillColor, borderColor); boundaryFill4 (x , y - 1, fillColor, borderColor) }

Polygon Filling: Boundary-Fill Algorithm void boundaryFill4 (int x, int y, int fillColor, int borderColor) { int interiorColor; /* Set current color to fillColor, then perform following oprations. */ getPixel (x, y, interiorColor); if ((interiorColor != borderColor) && (interiorColor != fillColor)) setPixel (x, y); // Set pixel color to fillColor boundaryFill4 (x + 1, y , fillColor, borderColor); boundaryFill4 (x - 1, y , fillColor, borderColor); boundaryFill4 (x , y + 1, fillColor, borderColor); boundaryFill4 (x , y - 1, fillColor, borderColor) }

Polygon Filling: Boundary-Fill Algorithm 2 2 1 1

Polygon Filling: Boundary-Fill Algorithm 3 3 1 1

Polygon Filling: Boundary-Fill Algorithm 5 6 6 5 4 1 4 1

Polygon Filling: Boundary-Fill Algorithm 7 7 5 4 1 5 4 1

Polygon Filling: Boundary-Fill Algorithm 5 5 4 1 4 1

Polygon Filling: Boundary-Fill Algorithm 8 8 4 1 4 1

Polygon Filling: Boundary-Fill Algorithm 4 1 4 1

Polygon Filling: Boundary-Fill Algorithm 9 1 9 1

Polygon Filling: Boundary-Fill Algorithm 10 1 10 1

Polygon Filling: Boundary-Fill Algorithm 11 1 1 11

Polygon Filling: Boundary-Fill Algorithm 12 1 1 12

Polygon Filling: Boundary-Fill Algorithm 1 1

Polygon Filling: Flood-Fill Algorithm void floodFill4 (int x, int y, int fillColor, int interiorColor) { int color; /* Set current color to fillColor, then perform following operations. */ getPixel (x, y, color); if (color = interiorColor) { setPixel (x, y); // Set pixel color to fillColor floodFill4 (x + 1, y, fillColor, interiorColor); floodFill4 (x - 1, y, fillColor, interiorColor); floodFill4 (x, y + 1, fillColor, interiorColor); floodFill4 (x, y - 1, fillColor, interiorColor) }

OpenGL Polygon Functions glRect*(x1, y1, x2, y2); Ex: i (integer) s (short) f (float) d (double) v (vector) Ex: glRecti(50, 250, 200, 100); int v1[ ]={50, 250}; int v2[ ]={200, 100}; glRectiv(v1, v2); (50,250) (200,100)

OpenGL Ex: GL_POLYGON GL_TRIANGLES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN glBegin (GL_POLYGON); glVertex2iv(p1); glVertex2iv(p2); glVertex2iv(p3); glVertex2iv(p4); glVertex2iv(p5); glVertex2iv(p6); glEnd(); p6 p5 p1 p4 p2 p3 GL_POLYGON GL_TRIANGLES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN

OpenGL Ex: GL_QUADS GL_QUAD_STRIP glBegin (GL_QUADS); glVertex2iv(p1); glEnd(); p8 p1 p4 p5 p7 p6 p3 p2 GL_QUADS GL_QUAD_STRIP