Computer Graphics. Modelling in 2D. 2D primitives. Lines and Polylines. OpenGL polygon primitives. Special polygons

Similar documents
Graphics Output Primitives

GRAPHICS OUTPUT PRIMITIVES

Computer Graphics. Lecture 3 Graphics Output Primitives. Somsak Walairacht, Computer Engineering, KMITL

CSC Computer Graphics

OUTPUT PRIMITIVES. CEng 477 Introduction to Computer Graphics METU, 2007

CS 450: COMPUTER GRAPHICS RASTERIZING LINES SPRING 2016 DR. MICHAEL J. REALE

Two Dimensional Viewing

Computer Graphics. Computer Graphics. Lecture 3 Line & Circle Drawing

Prof. Feng Liu. Fall /25/2018

CPSC / Scan Conversion

Raster Displays and Scan Conversion. Computer Graphics, CSCD18 Fall 2008 Instructor: Leonid Sigal

Computer Graphics. - Rasterization - Philipp Slusallek

Scan Converting Lines

Chapter 8: Implementation- Clipping and Rasterization

CSCI 4620/8626. Coordinate Reference Frames

Today s class. Geometric objects and transformations. Informationsteknologi. Wednesday, November 7, 2007 Computer Graphics - Class 5 1

Graphics (Output) Primitives. Chapters 3 & 4

CS 548: COMPUTER GRAPHICS DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE

Announcements. Midterms graded back at the end of class Help session on Assignment 3 for last ~20 minutes of class. Computer Graphics

Raster Scan Displays. Framebuffer (Black and White)

0. Introduction: What is Computer Graphics? 1. Basics of scan conversion (line drawing) 2. Representing 2D curves

OpenGL Graphics System. 2D Graphics Primitives. Drawing 2D Graphics Primitives. 2D Graphics Primitives. Mathematical 2D Primitives.

Last Time. Correct Transparent Shadow. Does Ray Tracing Simulate Physics? Does Ray Tracing Simulate Physics? Refraction and the Lifeguard Problem

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005

Clipping and Scan Conversion

Line Drawing Week 6, Lecture 9

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

Solid Modelling. Graphics Systems / Computer Graphics and Interfaces COLLEGE OF ENGINEERING UNIVERSITY OF PORTO

R asterisation. Part I: Simple Lines. Affine transformation. Transform Render. Rasterisation Line Rasterisation 2/16

Realtime 3D Computer Graphics Virtual Reality

COMP371 COMPUTER GRAPHICS

From Ver(ces to Fragments: Rasteriza(on

Reteaching Golden Ratio

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

Scan Conversion. CMP 477 Computer Graphics S. A. Arekete

CS452/552; EE465/505. Clipping & Scan Conversion

Computer Graphics : Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling

9. Three Dimensional Object Representations

CSC Computer Graphics

The graphics pipeline. Pipeline and Rasterization. Primitives. Pipeline

Chapter 3. Sukhwinder Singh

Computer Graphics and GPGPU Programming

UNIT -8 IMPLEMENTATION

End-Term Examination

Pipeline and Rasterization. COMP770 Fall 2011

Rasterization. CS 4620 Lecture Kavita Bala w/ prior instructor Steve Marschner. Cornell CS4620 Fall 2015 Lecture 16

Rasterization, or What is glbegin(gl_lines) really doing?

Chapter - 2: Geometry and Line Generations

Scan Conversion. Drawing Lines Drawing Circles

Computer Graphics. Lecture 2. Doç. Dr. Mehmet Gokturk

Tópicos de Computação Gráfica Topics in Computer Graphics 10509: Doutoramento em Engenharia Informática. Chap. 2 Rasterization.

Announcements. Tutorial this week Life of the polygon A1 theory questions

Output Primitives Lecture: 4. Lecture 4

MATH STUDENT BOOK. 10th Grade Unit 9

CS335 Fall 2007 Graphics and Multimedia. 2D Drawings: Lines

1 Introduction to Graphics

The Traditional Graphics Pipeline

SOME 024: Computer Aided Design. E. Rozos

Summer Dear Geometry Students and Parents:

In today s lecture we ll have a look at: A simple technique The mid-point circle algorithm

Course Title: Computer Graphics Course no: CSC209

Geometric and Solid Modeling. Problems

Line Drawing. Introduction to Computer Graphics Torsten Möller / Mike Phillips. Machiraju/Zhang/Möller

Polygon Filling. Can write frame buffer one word at time rather than one bit. 2/3/2000 CS 4/57101 Lecture 6 1

VALLIAMMAI ENGINEERING COLLEGE

CSG obj. oper3. obj1 obj2 obj3. obj5. obj4

(Refer Slide Time: 00:03:51)

Computer Graphics D Graphics Algorithms

Rasterization. CS4620 Lecture 13

The Traditional Graphics Pipeline

Output Primitives Lecture: 3. Lecture 3. Output Primitives. Assuming we have a raster display, a picture is completely specified by:

Standard 1 Students will expand number sense to include integers and perform operations with whole numbers, simple fractions, and decimals.

SEOUL NATIONAL UNIVERSITY

Introduction to Computer Graphics

RASTERIZING POLYGONS IN IMAGE SPACE

Lecture 6 of 41. Scan Conversion 1 of 2: Midpoint Algorithm for Lines and Ellipses

Lecture 6 of 41. Scan Conversion 1 of 2: Midpoint Algorithm for Lines and Ellipses

Surface shading: lights and rasterization. Computer Graphics CSE 167 Lecture 6

Using Characteristics of a Quadratic Function to Describe Its Graph. The graphs of quadratic functions can be described using key characteristics:

The Traditional Graphics Pipeline

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

This lesson gives students practice in graphing

5 and Parallel and Perpendicular Lines

Geometric Modeling. Introduction

Midterm Review. Wen-Chieh (Steve) Lin Department of Computer Science

3D Representation and Solid Modeling

Introduction to Solid Modeling Parametric Modeling. Mechanical Engineering Dept.

Output Primitives. Dr. S.M. Malaek. Assistant: M. Younesi

Chapter 12 Solid Modeling. Disadvantages of wireframe representations

CS 130. Scan Conversion. Raster Graphics

STANDARDS OF LEARNING CONTENT REVIEW NOTES GEOMETRY. 3 rd Nine Weeks,

Line Drawing. Foundations of Computer Graphics Torsten Möller

Lecture 3.4 Differential Equation Based Schemes

L1 - Introduction. Contents. Introduction of CAD/CAM system Components of CAD/CAM systems Basic concepts of graphics programming

Table of Contents. Introduction to the Math Practice Series...1

Rasterization: Geometric Primitives

Topic #1: Rasterization (Scan Conversion)

Glossary alternate interior angles absolute value function Example alternate exterior angles Example angle of rotation Example

NONCONGRUENT EQUIDISSECTIONS OF THE PLANE

Topics. From vertices to fragments

Transcription:

Computer Graphics Modelling in D Lecture School of EECS Queen Mar, Universit of London D primitives Digital line algorithms Digital circle algorithms Polgon filling CG - p.hao@qmul.ac.uk D primitives Line segments Ellipses and circles Polgons Curves Lines and Pollines Lines drawn between ordered points to create more comple forms called pollines. Same first and last point make closed polline or polgon. If it does not intersect itself, called simple polgon. Conve Polgons: For ever pair of points in the polgon, the line between them is full contained in the polgon. Concave Polgons: Not conve: some two points in the polgon are joined b a line not full contained in the polgon. Polline Polgon Conve polgon Concave polgon CG - p.hao@qmul.ac.uk CG - p.hao@qmul.ac.uk 4 Special polgons OpenGL polgon primitives v 4 v v 5 v v 4 v 4 v v 5 v 5 v6 v v 6 v v v 6 v v 8 v 7 v v 8 v 7 v v 8 v 7 Triangles Quads Polgon triangle square rectangle v v v 5 v v 4 v 5 v v 4 v 6 v 8 v v v 4 v 6 Triangle Strip v Triangle Fan v v v 5 Quad Strip v 7 CG - p.hao@qmul.ac.uk 5 CG - p.hao@qmul.ac.uk 6

Scan Converting Lines Mathematics of Lines Rasterization (scan-conversion) : turn D primitives into sets of piels Equation of a (D) line: a + b + c = 0 Direction: ( b, a) Normal vector: (a, b) ideal line Parametric equation of a segment [P0-P] : (t) = 0 + t*(-0) = (-t)*0 + t* (t) = 0 + t*(-0) = (-t)*0 + t*, where t in [0..] O For a line from (0, 0) to (, ), the line equation is = m + c where m is the slope of the line m = ( 0) / ( 0) c = 0 m*0 Note that we can restrict out attention to lines of slope between - and. CG - p.hao@qmul.ac.uk 7 CG - p.hao@qmul.ac.uk 8 Naive algorithm Clever approaches faster. start with the smallest of (0,0). compute corresponding value of. SetPiel(, round()) 4. increment and loop until reaching ma(,) Cost: float multiplication + float addition + round per loop O Use integer calculations Avoid divides and multiplies Use incremental computations Use spatial coherence CG - p.hao@qmul.ac.uk 9 CG - p.hao@qmul.ac.uk 0 Basic Incremental Algorithm Digital differential analzer (DDA) algorithm: void Line(int 0, int 0, int, int ) { int ; float d, d,, m; d = - 0; /* Floating */ d = - 0; /* Floating */ m = d/d; /* Floating division */ = 0; /* Floating */ for ( = 0; <=,++){ SetPiel(, round()); += m; /* Increment */ Cost: float add + round per loop CG - p.hao@qmul.ac.uk Midpoint Line Algorithm Line equation: ( 0)( 0) = ( 0)( 0) or F(,) = 0 F(,) = ( 0)( 0) ( 0)( 0) = ( 0) ( 0) ( 0)0+( 0)0 F(+, ) F(,) = ( 0) F(+, +) F(,) = ( 0) ( 0) F(+, +/) F(,) = ( 0) ( 0)/ d = ( 0) ( 0) If point P(,) drawn, the net point is either P(+,) or P(+,+) To decide which point, use the relative position of the midpoint M = (+, +/) with respect to the line The distance d can be computed incrementall with onl one or two integer adds per loop! CG - p.hao@qmul.ac.uk

Midpoint Line Algorithm Scan Converting Circles Bresenham's algorithm: void MidpointLine(int 0, int 0, int, int ) { int d,d,incre,incrne,d,,; d=-0; d=-0; d=*d-d; /* initial value of d */ incre=*d; /* increment for move to E */ incrne=*d-*d; /* increment for move to NE */ =0; =0; DrawPiel(,) /* draw the first piel */ while (<){ if (d<=0){ /* choose E */ d+=incre; ++; /* move E */ F(, )<0 else { /* choose NE */ NE d+=incrne; ++; ++; /* move NE */ SetPiel (,); (i, i) E Cost: integer add per piel F(, )>0 CG - p.hao@qmul.ac.uk F(, )=0 (i+, i+/) For a circle + = R, we could use the following algorithm: for (= R; <=R; ++) { SetPiel (, round(sqrt(r* R * )); SetPiel (, round(sqrt(r* R * )); However, this simple method is inefficient And the circle has large gaps for the value of close to R The large gaps can be avoided b using the parametric equations of the circle: = R cos(a), = R sin(a) However the inefficienc problems remain. CG - p.hao@qmul.ac.uk 4 R Eight-Wa Smmetr we can draw a circle smmetricall b eight-sections if we draw a piel (, ) then we can also draw (, ), (, ), (, ), (, ), (, ), (, ), (, ). Therefore, we onl need consider 45 O of a circle, from =0 and = to ==R/sqrt(). Midpoint Circle Algorithm Circle equation: + = R or F(,) = 0 F(,)= + R = 0 F(+, /) F(,) = + 5/4 d = + 5/4; d(0,r) = 5/4 R E move: F(+, /) F(+, /) = + d new = d old + + SE move: F(+, /) F(+, /) = ( ) + 5 d new = d old + ( ) + 5 CG - p.hao@qmul.ac.uk 5 CG - p.hao@qmul.ac.uk 6 Midpoint Circle Algorithm void MidpointCircle (int radius) { /* Assume integer radius. */ int,,d = 0; = radius; d = - radius; /* Initialization */ SetPiel(,); while (>) { if (d < 0) { /* Choose E */ d += * + ; ++; else { /* Choose SE */ d += *(-)+5; ++; --; SetPiel(,); all integer computations, shift and or adds per piel Filling Shapes Filling Shapes: Turn on all the piels on a raster displa that are INSIDE a mathematical shape. Questions before filling: Is the shape closed with a boundar? Which piel is inside and which is outside? What color/pattern should the shape be filled with? CG - p.hao@qmul.ac.uk 7 CG - p.hao@qmul.ac.uk 8

ODL DCS ODL DCS Filling Rectangles Filling Polgons If the rectangle is aligned with the and ais, then we can easil determine which piels lie inside the rectangle. for = min to ma for = min to ma SetPiel (, ) Use scan lines Edge coherence Finding intersections 4 0 8 6 4 0 0 4 6 8 0 4 CG - p.hao@qmul.ac.uk 9 CG - p.hao@qmul.ac.uk 0 Geometric Modelling Geometric Modelling Hierarch in Geometric Models Modelling transformations Surface modelling Solid Modelling Point-based Surface-based Constructive CG - p.hao@qmul.ac.uk CG - p.hao@qmul.ac.uk Hierarch in Geometric Models Comple objects can be built using applicationspecific atomic components. Smbolized b various tree structures or DAG (Directed Acclic Graph). QM Tree upperbod leg leg arm arm foot foot hand hand DAG upperbod leg arm hand foot Binar Tree upperbod arm leg hand arm foot leg hand foot Hierarch in Geometric Models If a child-sibling tree (binar tree) is emploed, preorder traversal can be used for rendering. Parent calls child and passes geometric parameters to child. QM Tree upperbod leg leg arm arm foot foot hand hand DAG Binar Tree upperbod upperbod leg arm leg arm foot hand arm foot leg hand hand foot CG - p.hao@qmul.ac.uk CG - p.hao@qmul.ac.uk 4 4

Modelling transformations Surface modelling Boundar Representations CG - p.hao@qmul.ac.uk 5 CG - p.hao@qmul.ac.uk 6 Representing Polgon Meshes Representing Polgon Meshes A polgon mesh is a collection of polgons or faces, which are together connected to form the skin of the object. Faces Edges, the boundar between faces Vertices, the boundaries between edges, or where three or more faces meet Normals, teture coordinates, colors, shading coefficients, etc Polgon Mesh Verte list locations of the vertices, geometric information Edge list indees into end vertices of edges, topological information Face list indees into vertices and normal lists, topological information Normal list directions of the normal vectors, orientation information. CG - p.hao@qmul.ac.uk 7 CG - p.hao@qmul.ac.uk 8 Representing Polgon Meshes Euler s Formula: V E + F = verte list and face list are enough. Polgon Mesh Eample A cube: Coordinates of Vertices (D,,, and z for each verte): -, # Verte 0 - -, # Verte - - -, # Verte - -, # Verte, # Verte 4 -, # Verte 5 - -, # Verte 6 -, # Verte 7 Lists of 6 Faces (vertices are referenced to the vertices above, - marks the end of the verte list of a face) :,, 0,, -, # Front face=verte,,0, 0,, 5, 4, -, # Right side 7, 6,,, -, # Left side 4, 5, 6, 7, -, # Back 0, 4, 7,, -, # Top,, 6, 5, - # Bottom CG - p.hao@qmul.ac.uk 9 CG - p.hao@qmul.ac.uk 0 5

Polgon Mesh Eample Plane Equations A House : Coordinates of Vertices : 0, # Verte 0 0 -, # Verte - 0 -, # Verte - 0, # Verte, # Verte 4 -, # Verte 5 - -, # Verte 6 -, # Verte 7 0 4 0 # Verte 8 List of Faces : 0,,,, -, 0,, 5, 4, -,,, 6, 5, -,,, 7, 6, -,, 0, 4, 7, -, 4, 5, 8, -, 5, 6, 8, -, 6, 7, 8, -, 7, 4, 8, - The equation of a plane is A + B + Cz + D = 0 Its normal vector is (A, B, C). Three points determine a plane: A B Cz D 0 A B Cz D 0 A B Cz D 0 A B Cz D 0 The plane equation: z A z B 0 z C z D z z 0 z z z z z z z + z z z z 0 z CG - p.hao@qmul.ac.uk CG - p.hao@qmul.ac.uk Relative location with a plane A Nonsense Object A B Cz D 0 0 0 outside on inside Perpendicular distance from a point (,, z) to a plane : d A B Cz D A B C CG - p.hao@qmul.ac.uk CG - p.hao@qmul.ac.uk 4 What do we mean b a solid object? Three-Levels of Modeling finite three dimensional rigid closed finitel describable with a determinable boundar World Phsical objects Solid Mathematical objects theor Point-set topolog Algebraic topolog Bod of mathematics Representation realization B-rep CSG Decomposition CG - p.hao@qmul.ac.uk 5 CG - p.hao@qmul.ac.uk 6 6

Regularized Boolean Set Operations Primitive instancing CG - p.hao@qmul.ac.uk 7 CG - p.hao@qmul.ac.uk 8 Sweep Representations Boundar Representations Z Z sweep sweep X Y Y X CG - p.hao@qmul.ac.uk 9 CG - p.hao@qmul.ac.uk 40 Spatial-Partitioning Representations Constructive Solid Geometr (CSG) Cell decomposition Spatial occupanc enumeration Octrees CSG Tree Binar Space Partition A B D B out C C D A in out in out CG - p.hao@qmul.ac.uk 4 CG - p.hao@qmul.ac.uk 4 7

Object Modelling Summar Voels Polgon Mesh Octree CSG Tree B-rep CG - p.hao@qmul.ac.uk 4 8