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

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

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

Chapter - 2: Geometry and Line Generations

From Ver(ces to Fragments: Rasteriza(on

GRAPHICS OUTPUT PRIMITIVES

Computer Graphics: Graphics Output Primitives Line Drawing Algorithms

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

1 Introduction to Graphics

Einführung in Visual Computing

Unit 2 Output Primitives and their Attributes

Rasterization: Geometric Primitives

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

CS 130. Scan Conversion. Raster Graphics

Graphics (Output) Primitives. Chapters 3 & 4

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

UNIT 2 GRAPHIC PRIMITIVES

MODULE - 4. e-pg Pathshala

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

Chapter 8: Implementation- Clipping and Rasterization

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

Output Primitives Lecture: 4. Lecture 4

Scan Converting Circles

Rendering. A simple X program to illustrate rendering

Chapter 3. Sukhwinder Singh

Scan Conversion. Drawing Lines Drawing Circles

Line Drawing Week 6, Lecture 9

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

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

CSCI 4620/8626. Coordinate Reference Frames

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

Overview of Computer Graphics

CS Rasterization. Junqiao Zhao 赵君峤

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Computer Graphics

Line Drawing. Foundations of Computer Graphics Torsten Möller

Topic #1: Rasterization (Scan Conversion)

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

Digital Differential Analyzer Bresenhams Line Drawing Algorithm

UNIT -8 IMPLEMENTATION

COMP371 COMPUTER GRAPHICS

CPSC / Scan Conversion

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

Graphics Output Primitives

Display Technologies: CRTs Raster Displays

Computer Graphics D Graphics Algorithms

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

CS 543: Computer Graphics. Rasterization

Raster Scan Displays. Framebuffer (Black and White)

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

Efficient Plotting Algorithm

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

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

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

Department of Computer Sciences Graphics Fall 2003 (Lecture 2) Pixels

Painter s HSR Algorithm

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

A is any set of ordered pairs of real numbers. This is a set of ordered pairs of real numbers, so it is a.

CS2401 Computer Graphics

Computer Graphics. Chapter 4 Attributes of Graphics Primitives. Somsak Walairacht, Computer Engineering, KMITL 1

Scan Converting Lines

2D Image Synthesis. 2D image synthesis. Raster graphics systems. Modeling transformation. Vectorization. u x u y 0. o x o y 1

Computer Graphics. Attributes of Graphics Primitives. Somsak Walairacht, Computer Engineering, KMITL 1

Computer Graphics: 6-Rasterization

with a Digital Differential Algorithm tom/lecture-notes/graphics/dda-circle/dda-circle.

Rasterization. CS4620/5620: Lecture 12. Announcements. Turn in HW 1. PPA 1 out. Friday lecture. History of graphics PPA 1 in 4621.

UNIT 2 Scan Conversion Techniques and Image Representation Unit-02/Lecture-01

Department of Computer Science Engineering, Mits - Jadan, Pali, Rajasthan, India

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

CS6504 & Computer Graphics Unit I Page 1

(Refer Slide Time: 00:03:51)

1 Some easy lines (2, 17) (10, 17) (18, 2) (18, 14) (1, 5) (8, 12) Check with a ruler. Are your lines straight?

Rendering. A simple X program to illustrate rendering

Computer Graphics (CS 543) Lecture 10: Rasterization and Antialiasing

A New Line Drawing Algorithm Based on Sample Rate Conversion

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

Computer Graphics. - Rasterization - Philipp Slusallek

Computer Graphics D Graphics Algorithms

CS-321 Thursday 12 September 2002 Quiz (3 pts.) What is the purpose of a control grid in a cathode ray tube (CRT)?

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

CS602 MCQ,s for midterm paper with reference solved by Shahid

RASTERIZING POLYGONS IN IMAGE SPACE

Direction Fields; Euler s Method

More Raster Line Issues. Bresenham Circles. Once More: 8-Pt Symmetry. Only 1 Octant Needed. Spring 2013 CS5600

Computer Graphics Lecture Notes

Each point P in the xy-plane corresponds to an ordered pair (x, y) of real numbers called the coordinates of P.

Realtime 3D Computer Graphics Virtual Reality

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

UNIT I INTRODUCTION. Survey of Computer Graphics

MET71 COMPUTER AIDED DESIGN

CSC Computer Graphics

Section 1.1 The Distance and Midpoint Formulas

Computer Graphics. Chapter 3 Computer Graphics Software

Pipeline implementation II

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Lab Manual. Computer Graphics. T.E. Computer. (Sem VI)

Fall CSCI 420: Computer Graphics. 7.1 Rasterization. Hao Li.

Implementation III. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

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

The Traditional Graphics Pipeline

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY CS2401 COMPUTER GRAPHICS QUESTION BANK

Transcription:

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

Output Primitives Output Primitives: Basic geometric structures (points, straight line segment, circles and other conic sections, quadric surfaces, spline curve and surfaces, polygon color areas, and character strings) These picture components are often defined in a continuous space.

Output Primitives In order to draw the primitive objects, one has to first scan convert the object. Scan convert: Refers to he operation of finding out the location of pixels to the intensified and then setting the values of corresponding bits, in the graphic memory, to the desired intensity code.

Output Primitives Each pixel on the display surface has a finite size depending on the screen resolution and hence a pixel cannot represent a single mathematical point.

Scan Converting A Point

Scan Converting A Point A mathematical point (x,y) needs to be scan converted to a pixel at location (x, y ).

Scan Converting A Point x =Round(x) and y =Round(y) All points that satisfy: x x < x + 1 are mapped to pixel (x,y ) y y y 1 < +

Scan Converting A Point x =Round(x+0.5) and y =Round(y+o.5) All points that satisfy: x 0.5 x < x + 0.5 are mapped to pixel (x,y ) y 0.5 y < y + 0. 5

Scan Converting A Line

Scan Converting A Line The Cartesian slope- intercept equation for a straight line is: 1 2 1 2 x x y y m = b x m y + = 1 x 1 m y b = x m y = m y x =

Scan Converting A Line These equation form the basic for determining deflection voltage in analog devices. y = m x x = y m m <1 m >1

Scan Converting A Line On raster system, lines are plotted with pixels, and step size (horizontal & vertical direction) are constrained by pixel separation.

Scan Converting A Line We must sample a line at discrete positions and determine the nearest pixel to the line at each sampled position.

Digital Differential Analyzer (DDA Algorithm)

DDA Algorithm Algorithm is an incremental scan conversion method. Based on calculating either x or If m <1, ( x =1) y y = m x y = y + K +1 k m

DDA Algorithm If m >1, ( y = 1) y x = m 1 x =x + m K +1 k If ( x = 1) y = m x y K +1 = y m k

Bresenham s Line Algorithm

Bresenham s Line Algorithm A highly efficient incremental method for scan converting lines. Using only incremental integer calculation. By testing the sign of an integer parameter, whose value is proportional to the difference between the separation of two pixel positions from the actual line path.

Bresenham s Line Algorithm A highly efficient incremental method for scan converting lines. Using only incremental integer calculation. By testing the sign of an integer parameter, whose value is proportional to the difference between the separation of two pixel positions from the actual line path.

Bresenham s Line Algorithm

Bresenham s Line Algorithm

Bresenham s Line Algorithm y k+1 y y k } } d 2 d 1 x k+1

Bresenham s Line Algorithm d 1 = y - y k = m (x k + 1) + b - y k d 2 = (y k + 1) - y = y k + 1 - m (x k + 1) b d 1 -d 2 = 2 m (x k + 1) - 2 y k + 2b -1

Bresenham s Line Algorithm P k = X ( d 1 -d 2 ) = 2 Y. x k -2 X. y k + c c = constante = 2 Y + X (2b -1)

Let's get rid of multiplications P k+1 = 2 Y. x k+1-2 X.y + c P k+1 -P k = 2 Y (x k+1 -x k ) -2 X (y k+1 -y k ) (get rid of the constance) P k+1 = P k + 2 Y - 2 X (y k+1 -y k ) P k+1 = P k + 2 Y or = P k + 2( Y X ) with (y k+1 -y k ) = 0 or 1 depending on P k sign

Bresenham s Line Algorithm P 0 = X (d 1 -d 2 ) = X[2m(x 0 +1)-2y 0 +2b-1] = X[2(mx 0 +b-y 0 )+2m-1] m= y/x 0 P 0 =2 Y - X

Bresenham s Line Algorithm Example: Digitize the line with endpoint (20,10) and (30,18) X=10 Y= 8 P0=2 Y x=6 2 Y =16 2( Y X)=-4 P0=2 Y X Pk+1 = Pk + 2 Y or = Pk + 2( Y X)

Circle Generation Algorithms

Circle Generation Algorithms The equation of a circle: We could solve for y in terms of x

Circle Generation Algorithms The spacing between plotted pixel positions is not uniform.

Circle Generation Algorithms Computation can be reduced by considering the symmetry of circles 8 -Way symmetry

Midpoint Circle Algorithm

Circle Generation Algorithms As in the line algorithm, we sample at unit intervals and determine the closet pixel position to the circle path at each step.

Circle Generation Algorithms Points are generated from 90º to 45º, moves will be made only in the +x and y direction. positive x direction over this octant and use a decision parameter

Circle Generation Algorithms We define a circle function: < 0 f ( x, y) = x 2 + y 2 r 2 = 0 circle > o

Circle Generation Algorithms Midpoint ( x i 1, y + i 1 ) 2 Consider the coordinates of the point halfway between pixel T and pixel S Midpoint

Circle Generation Algorithms We use it to define a decision parameter p i = f 1 ) 2 1 ) 2 ( x + 1, y = ( x + 1) 2 + ( y 2 r 2 i i i

Circle Generation Algorithms p i If is negative, the midpoint is inside the pixel, and we choose pixel T. < 0 If p 0 we choose pixel S. i

Circle Generation Algorithms Parameter for the next step is: p 1 = + 1) 2 + ( ) i+ 1 i+ 1 i+ 1 2 ( x y r 2 since x = x +1 i + 1 i

Circle Generation Algorithms If T is chosen ( ) we have: p i < 0 If pixel S is chosen ( ) we have p i 0

Circle Generation Algorithms In terms of

Circle Generation Algorithms Initial value for the decision parameter using the original function of (0,r) When r is an integer we can simply set

Circle Generation Algorithms

Circle Generation Algorithms int x = 0; int y = radius; int p = 1 - radius; circlepoints(xcenter, ycenter, x, y, pix); while (x < y) { x++; if (p < 0) { p += 2*x+1; } else { y--; p += 2*(x-y+1); } circlepoints(xcenter, ycenter, x, y, pix); }

Circle Generation Algorithms Example: A circle radius r=10 x=0 to x=y P 0 =1-r = -9

Exercises

1. Scan Converting Arcs And Sectors?

Character Generation

Character Generation Letters, numbers, and other character can be displayed in a variety of size and styles.

Character Generation Typeface: The overall design style for a set of characters is call typeface: Zar, nazanin, Titr. Font: Referred to a set of cast metal character forms in a particular size and forma: 10 point Zar.

Character Generation Two different representation are used for storing computer fonts: 1. Bitmap font (or bitmapped font) 2. Outline font

Bitmap font Bitmap font (or bitmapped font): A simple method for representing the character shapes in a particular typeface is to use rectangular grid pattern.

Bitmap font The character grid only need to be mapped to a frame buffer position. Bitmap fonts required more space, because each variation (size and format) must be stored in a font cash. Bold Italic

Outline Font Graphic primitives such as lines and arcs are used to define the outline of each character. Require less storage since variation does not require a distinct font cash.

Outline Font We can produce boldface, italic, or different size by manipulating the curve definition for the character outlines. It does take more time to process the outline fonts, because they must be scan converted into frame buffer.