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

Similar documents
GRAPHICS OUTPUT PRIMITIVES

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

CSC Computer Graphics

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

CSCI 4620/8626. Coordinate Reference Frames

Prof. Feng Liu. Fall /25/2018

Computer Graphics. Chapter 3 Computer Graphics Software

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

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

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

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

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

Graphics Output Primitives

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

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

Computer Graphics: Graphics Output Primitives Line Drawing Algorithms

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

From Ver(ces to Fragments: Rasteriza(on

Two Dimensional Viewing

Line Drawing. Foundations of Computer Graphics Torsten Möller

This library uses only GL functions but contains code for creating common objects and simplifying viewing.

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

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

UNIT 2 GRAPHIC PRIMITIVES

UNIT -8 IMPLEMENTATION

CPSC / Scan Conversion

Computer Graphics D Graphics Algorithms

1 Introduction to Graphics

Line Drawing Week 6, Lecture 9

3.2 Polynomial Functions of Higher Degree

CS 130. Scan Conversion. Raster Graphics

Precalculus, IB Precalculus and Honors Precalculus

Rasterization: Geometric Primitives

Chapter 3: Graphics Output Primitives. OpenGL Line Functions. OpenGL Point Functions. Line Drawing Algorithms

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

Section 9.3: Functions and their Graphs

Chapter - 2: Geometry and Line Generations

CS 4731: Computer Graphics Lecture 21: Raster Graphics: Drawing Lines. Emmanuel Agu

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

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

Computer Graphics, Chapt 08

Test Name: Chapter 3 Review

(Refer Slide Time: 00:03:51)

The Traditional Graphics Pipeline

Graphics (Output) Primitives. Chapters 3 & 4

Display Technologies: CRTs Raster Displays

Output Primitives Lecture: 4. Lecture 4

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

Points and lines. x x 1 + y 1. y = mx + b

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Computer Graphics D Graphics Algorithms

Section 1.1 The Distance and Midpoint Formulas

1/29/13. Computer Graphics. Transformations. Simple Transformations

Realtime 3D Computer Graphics Virtual Reality

Digital Differential Analyzer Bresenhams Line Drawing Algorithm

Rendering. A simple X program to illustrate rendering

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

Assignment 1. Simple Graphics program using OpenGL

10.2: Parabolas. Chapter 10: Conic Sections. Conic sections are plane figures formed by the intersection of a double-napped cone and a plane.

The Traditional Graphics Pipeline

The Traditional Graphics Pipeline

Efficient Plotting Algorithm

Scan Conversion. Drawing Lines Drawing Circles

2D Graphics Primitives II. Additional issues in scan converting lines. 1)Endpoint order. Want algorithms to draw the same pixels for each line

Reteaching Golden Ratio

MODULE - 4. e-pg Pathshala

Chapter 8: Implementation- Clipping and Rasterization

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

Topic #1: Rasterization (Scan Conversion)

Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 14

Lines and Their Slopes

CS Rasterization. Junqiao Zhao 赵君峤

Section 4.2 Graphing Lines

CS 543: Computer Graphics. Rasterization

CS2401 COMPUTER GRAPHICS ANNA UNIV QUESTION BANK

Polar Functions Polar coordinates

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

Beecher J.A, Penna J.A., Bittinger M.L. Algebra and Trigonometry (3ed, Addison Wesley, 2007) 58 Chapter 1 Graphs, Functions, and Models

Scan Converting Circles

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

Computer Graphics: Line Drawing Algorithms

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

C URVES AND V ECTORS

Name: Date: Practice Final Exam Part II covering sections a108. As you try these problems, keep referring to your formula sheet.

A New Line Drawing Algorithm Based on Sample Rate Conversion

Graphics System. Processor. Output Display. Input Devices. Frame Buffer. Memory. Array of pixels. Resolution: # of pixels Depth: # of bits/pixel

Computer Graphics. - Rasterization - Philipp Slusallek

Overview of Computer Graphics

Developed in Consultation with Tennessee Educators

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

Functions Review Packet from November Questions. 1. The diagrams below show the graphs of two functions, y = f(x), and y = g(x). y y

Graphics and Visualization

Unit 2 Output Primitives and their Attributes

Viewing and Projection

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

Einführung in Visual Computing

4.6 Graphs of Other Trigonometric Functions

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

8.6 Three-Dimensional Cartesian Coordinate System

Transcription:

OUTPUT PRIMITIVES CEng 477 Introduction to Computer Graphics METU, 007

Recap: The basic forward projection pipeline: MCS Model Model Modeling Transformations M M 3D World Scene Viewing Transformations V 3D View Scene Model M3 WCS VCS P Clip Normalize D/3D Device Scene Rasterization Projection NDCS D Image DCS SCS

Screen vs. World coordinate sstems Objects positions are specified in a Cartesian coordinate sstem called World Coordinate Sstem which can be three dimensional and real-valued. Locations on a video monitor are referenced in integer screen coordinates. Therefore object definitions has to be scan converted to discrete screen coordinate locations to be viewed on a video monitor.

Specification of a D WCS in OpenGL glmatrimode (GL_PROJECTION); glloadidentit (); gluorthod (min, ma, min, ma); Objects that are specified within these coordinate limits will be displaed within the OpenGL window.

Output Primitives Graphic SW and HW provide subroutines to describe a scene in terms of basic geometric structures called output primitives. Output primitives are combined to form comple structures Simplest primitives Point (piel) Line segment

Scan Conversion Converting output primitives into frame buffer updates. Choose which piels contain which intensit value. Constraints Straight lines should appear as a straight line primitives should start and end accuratel Primitives should have a consistent brightness along their length The should be drawn rapidl

OpenGL Point Functions glbegin (GL_POINTS); glvertei(50, 00); glvertei(75, 50); glvertei(00, 00); glend();

OpenGL Line Functions glbegin (GL_LINES); p3 glverteiv(p); glverteiv(p); glverteiv(p3); glverteiv(p4); glverteiv(p5); glend(); p p5 p4 p

OpenGL Line Functions glbegin (GL_LINE_STRIP); p3 glverteiv(p); glverteiv(p); glverteiv(p3); glverteiv(p4); glverteiv(p5); glend(); p p5 p4 p

OpenGL Line Functions glbegin (GL_LINE_LOOP); p3 glverteiv(p); glverteiv(p); glverteiv(p3); glverteiv(p4); glverteiv(p5); glend(); p p5 p4 p

Line Drawing Algorithms Simple approach: sample a line at discrete positions at one coordinate from start point to end point, calculate the other coordinate value from line equation (slope-intercept line equation). = m + b or b = m m end m = end start start Is this correct? If m>, If m, increment and find increment and find

Digital Differential Analzer Simple approach: too man floating point operations and repeated calculations Calculate from for a value m m m for, 0 m for, m m

DDA Is faster than directl implementing =m+b. No floating point multiplications. We have floating point additions onl at each step. But what about round-off errors? Can we get rid of floating point operations completel?

Bresenham's Line Algorithm DDA: Still floating point operations =m+b Assume m If alread at ( ( ( +, +,, ) if + ) if ), choices : d d lower lower d > d upper upper + d upper d lower = m( d lower + ) + b d d dupper = m( d upper lower = ( = + ) = m( + ) = + b + ) + b + m( + ) b + + +3 m = Δ Δ = end end start start define p = Δ( d lower c = Δ + Δ(b ) d upper ) = Δ Δ + c independent from piel position

choose else choose 0 if + < < upper lower p d d ) ( ) ( p p c p Δ Δ = + Δ Δ = + + + + + + at step +: ) ( p p Δ Δ + = + = + + + 0 if p was negative if p was positive to calculate p 0 at the starting piel position ( 0, 0 ) p c b b c c p Δ Δ = Δ Δ Δ + Δ = Δ Δ = + Δ Δ = + Δ Δ = ) ( 0 0 0 0 0 0 0 0

Bresenham s Line-Drawing Algorithm Input: two line end points ( 0, 0 ) and ( end draw ( 0, 0 ) p Δ-Δ; 0, end ) while < end + + if p 0 choose + ; p + p +Δ else choose + + +; p + p + Δ draw ( +, + ) -Δ + p p +

Eample from the tetboo Using Bresenham s algorithm digitize the line with endpoints (0,0) and (30,8)

Eample continued... 8 0 0 5 30

Plotted piels 8 0 0 5 30

Circle Generation Circles can be approimated b a set of straight lines. But, how man lines do we need for an acceptable representation? How do we determine end points of lines?

Circle Drawing in OpenGL Routines for drawing circles or ellipses are not included in the OpenGL core librar. GLU (OpenGL Utilit) librar has some routines for drawing spheres, clinders, B- splines. Rational B-splines can be used to displa circles and ellipses.

Circle Generation 0 0 unit steps in 0 r 0 r Computationall comple Non uniform spacing Polar coordinates: r cos c r sin c

Fied angular step size to have equall spaced points r cos r cos d r sin r sin d r cos cosd r sin sin d cosd sin d r sin cosd r cos sin d cosd sin d fied d so compute cosd and sin d initiall

Computation can be reduced b considering (-,) (,) smmetr of circles: Still too comple, multiplications, trigonometric calculations (-,) (-,-) (-,-) (,-) Bresenham's circle generation algorithm involves simple integer operations (comparing squares of piel separation distances) Midpoint Circle Algorithm avoids squaring and generates the same piels as Bresenhams s algorithm. (,) (,-)

Midpoint Circle Algorithm Consider the second octant. Increment, decide on select which of piels, ( +, ) or ( +, -) are closer to the circle b evaluating the circle function at the midpoint.

f (, ) p f, p f, p p p p = 0 0 if if 4 4 on the circle choose inside the circle choose 4 r = + r > 0 if outside the circle choose < r r r 4

p = p + ( + ) + ( + ) ( + ) + + where + is either or depending on the sign of p. if p < 0 p + = p + + 3 if p 0 p + = p + + 5 computing p 0 at ( 0, 0 ) = (0,r) p 0 = f (, r = + ( r = 5 4 r ) ) r if r is integer p 0 = r

Midpoint Circle Algorithm Input: radius r and circle center ( c, c ) draw(0+ c,r+ c ) (add c and c before plotting) p r; 0; r; while < if p < 0 choose + ; p + p + +3 else choose + ; p + p + + 5 + + draw ( + + c, + + c ) + ; +; p p +

if p < 0 choose + ; p + p + +3 else choose + ; p + p + + 5 0 ; 0 ; r 0 plot (0,0) p 0 9 choose E plot,0 p 9 3 4 choose E plot,0 p 4 4 3 3 choose SE plot 3,9 p 3 6 8 5 4 choose E plot 4,9 p 4 8 3 7 choose SE plot 5,8 p 7 0 6 5 6 choose SE plot 6,7 p 6 4 5 9 choose SE plot 7,6 - - - -

Ellipse Generation Similar to circle generation with mid-point. Inside test. Different formula for points up to the tangent =-, slope<. (0,b) to tangent: increment find tangent to (a,0): decrement find Mid-point algorithm is applicable to other polnomial equations: Parabola, Hperbola b =- a a b