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

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

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

Dr Pavan Chakraborty IIIT-Allahabad

CSC Computer Graphics

Raster Graphics Algorithms

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

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

GRAPHICS OUTPUT PRIMITIVES

CS 450: COMPUTER GRAPHICS 2D TRANSFORMATIONS SPRING 2016 DR. MICHAEL J. REALE

521493S Computer Graphics Exercise 3 (Chapters 6-8)

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

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

Line Drawing Week 6, Lecture 9

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

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

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

From Ver(ces to Fragments: Rasteriza(on

CPSC / Scan Conversion

Rendering. A simple X program to illustrate rendering

COMP371 COMPUTER GRAPHICS

Scan Converting Lines

CS5620 Intro to Computer Graphics

Prof. Feng Liu. Fall /25/2018

Simple example. Analysis of programs with pointers. Points-to relation. Program model. Points-to graph. Ordering on points-to relation

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

Display Technologies: CRTs Raster Displays

Output Primitives Lecture: 4. Lecture 4

Chapter 8: Implementation- Clipping and Rasterization

Shading Models. Simulate physical phenomena

Rendering. A simple X program to illustrate rendering

UNIT -8 IMPLEMENTATION

Line Drawing. Foundations of Computer Graphics Torsten Möller

(Refer Slide Time: 00:03:51)

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

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

Computer Graphics D Graphics Algorithms

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

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Perception of Shape from Shading

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

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

CS 543: Computer Graphics. Rasterization

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

Raster Scan Displays. Framebuffer (Black and White)

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

Scan Conversion. Drawing Lines Drawing Circles

Computer Graphics: Graphics Output Primitives Line Drawing Algorithms

Computer Graphics D Graphics Algorithms

UNIT 2 GRAPHIC PRIMITIVES

Scan Conversion. Lines and Circles

(Refer Slide Time: 9:36)

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

Introduction to Visualization and Computer Graphics

Section 4.3 Trigonometry Extended: The Circular Functions

Solution Notes. COMP 151: Terms Test

Chapter 7b - Point Estimation and Sampling Distributions

GRAPHING QUADRATIC FUNCTIONS IN STANDARD FORM

Rasterization: Geometric Primitives

1 Introduction to Graphics

Classes. Code Generation for Objects. Compiling Methods. Dynamic Dispatch. The Need for Dispatching CS412/CS413

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)

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

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

Graphics Output Primitives

To Do. Computer Graphics (Fall 2004) Course Outline. Course Outline. Motivation. Motivation

Truth Trees. Truth Tree Fundamentals

EF432. Introduction to spagetti and meatballs

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

Chapter 7, Part B Sampling and Sampling Distributions

Computer Graphics Lecture 5

Name Course Days/Start Time

Kinematics. Why inverse? The study of motion without regard to the forces that cause it. Forward kinematics. Inverse kinematics

Computer Graphics 7 - Rasterisation

K2 p K 3 p 2. 2 p K0.5 K1.5

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

Graphing Equations. The Rectangular Coordinate System

Digital Differential Analyzer Bresenhams Line Drawing Algorithm

Two Dimensional Viewing

Further Differentiation

A New Line Drawing Algorithm Based on Sample Rate Conversion

Gabriel Taubin. Desktop 3D Photography

Answers. Chapter 4. Cumulative Review Chapters 1 3, pp Chapter Self-Test, p Getting Started, p a) 49 c) e)

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

Topic #1: Rasterization (Scan Conversion)

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

THE INVERSE GRAPH. Finding the equation of the inverse. What is a function? LESSON

Determining the 2d transformation that brings one image into alignment (registers it) with another. And

Lecture06: Pointers 4/1/2013

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

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

1.5 Case Study. dynamic connectivity quick find quick union improvements applications

The graphics pipeline. Pipeline and Rasterization. Primitives. Pipeline

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

Clipping. Administrative. Assignment 1 Gallery. Questions about previous lectures? Overview of graphics pipeline? Assignment 2

A Method to Determine End-Points ofstraight Lines Detected Using the Hough Transform

Source Coding and express these numbers in a binary system using M log

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

Operations on Singly (Simply) Linked Lists

Algebra 1 Review. Properties of Real Numbers. Algebraic Expressions

Shuigeng Zhou. May 18, 2016 School of Computer Science Fudan University

Transcription:

Comuter Grahics Comuter Grahics Lecture 3 Line & Circle Drawing

Comuter Grahics Towards the Ideal Line We can onl do a discrete aroimation Illuminate iels as close to the true ath as ossible, consider bi-level disla onl Piels are either lit or not lit

Comuter Grahics What is an ideal line Must aear straight and continuous Onl ossible ais-aligned and 45 o lines Must interolate both defining end oints Must have uniform densit and intensit Consistent within a line and over all lines What about antialiasing? Must be efficient, drawn quickl Lots of them are required!!! 3

Comuter Grahics Simle Line Based on sloe-intercet algorithm from algebra: m b Simle aroach: increment, solve for Floating oint arithmetic required 4

Comuter Grahics Does it Work? It seems to work oka for lines with a sloe of or less, but doesn t work well for lines with sloe greater than lines become more discontinuous in aearance and we must add more than iel er column to make it work. Solution? - use smmetr. 5

Comuter Grahics Modif algorithm er octant OR, increment along -ais if d<d else increment along -ais 6

Comuter Grahics DDA algorithm DDA Digital Differential Analser finite differences 7 Treat line as arametric equation in t : ( ( ( ( t t t t, (, ( Start oint - End oint -

Comuter Grahics DDA Algorithm ( t ( t t( t( Start at t 0 At each ste, increment t b dt Choose aroriate value for dt Ensure no iels are missed: Imlies: d and dt < d dt < Set dt to maimum of d and d new new d d old old d dt d dt 8

Comuter Grahics DDA algorithm line(int, int, int, int { float,; int d -, d -; int n ma(abs(d,abs(d; float dt n, ddt d/dt, ddt d/dt; ; ; while( n-- { oint(round(,round(; ddt; ddt; } } n - range of t. 9

Comuter Grahics DDA algorithm Still need a lot of floating oint arithmetic. round s and adds er iel. Is there a simler wa? Can we use onl integer arithmetic? Easier to imlement in hardware. 0

Comuter Grahics Observation on lines. while( n-- { draw(,; move right; if( below line move u; }

Comuter Grahics Testing for the side of a line. Need a test to determine which side of a line a iel lies. Write the line in imlicit form: F (, a b c 0 If (b<0 F<0 for oints above the line, F>0 for oints below.

Comuter Grahics Testing for the side of a line. F(, a b c Need to find coefficients a,b,c. Recall elicit, sloe-intercet form : d m b and so b d 0 So: F(, d. d. c 0 3

Comuter Grahics Decision variable. Let s assume d/d < 0.5 (we can use smmetr Evaluate F at oint M Referred to as decision variable d F(, NE M E Previous Piel (, Choices for Current iel Choices for Net iel

Comuter Grahics Decision variable. Evaluate d for net iel, Deends on whether E or NE Is chosen : If E chosen : dnew F(, a( b( c Previous Piel (, NE E Choices for Current iel M Choices for Net iel d old But recall : a( So : F(, b( d new d d old old c a d 5

Comuter Grahics Decision variable. If NE was chosen : 3 3 dnew F(, a( b( c M So : Previous Piel (, NE E Choices for Current iel Choices for Net iel d new d d old old a b d d 6

Comuter Grahics Summar of mid-oint algorithm Choose between iels at each ste based uon the sign of a decision variable. Udate the decision variable based uon which iel is chosen. Start oint is siml first endoint (,. Need to calculate the initial value for d 7

Comuter Grahics Initial value of d. Start oint is (, d start F(, a( b( c a b c a F, a ( b b But (, is a oint on the line, so F(, 0 d start d d / Conventional to multil b to remove fraction doesn t effect sign. 8

Comuter Grahics Midoint algorithm void MidointLine(int,,, { int d-; int d-; int d*d-d; int incree*d; int incrne*(d-d; ; ; WritePiel(,; while ( < { if (d< 0 { dincre; } } } else { dincrne; ; ; } WritePiel(,; 9

Comuter Grahics Circle drawing. Can also use Bresenham to draw circles. Use 8-fold smmetr E M SE Previous Piel Choices for Current iel Choices for Net iel 0

Comuter Grahics Circle drawing. Imlicit form for a circle is: f (, ( ( r c c If SE is chosen d new d old ( 5 If E is chosen d new d old ( 3 Functions are linear equations in terms of (, Termed oint of evaluation

Comuter Grahics Summar of line drawing so far. Elicit form of line Inefficient, difficult to control. Parametric form of line. Eress line in terms of arameter t DDA algorithm Imlicit form of line Onl need to test for side of line. Bresenham algorithm. Can also draw circles.

Comuter Grahics Problems with Bresenham algorithm Piels are drawn as a single line unequal line intensit with change in angle. Piel densit.n iels/mm Piel densit n iels/mm Can draw lines in darker colours according to line direction. -Better solution : antialiasing! -(eg. Guta-Sroull algorithm 3

Comuter Grahics Guta-Sroull algorithm. Calculate the distance of the line and the iel center Adjust the colour according to the distance

Comuter Grahics Guta-Sroull algorithm. Calculate distance using features of mid-oint algorithm D v cosφ vd d d NE d d M D v Angle E 5

Comuter Grahics Guta-Sroull algorithm (cont Recall from the midoint algorithm: So ( a b 0 (doubled to avoid fraction F(, c For iel E: So: v (a c b a( b c v D Line to draw NE m v E Θ

Comuter Grahics Guta-Sroull algorithm (cont From revious slide: v a( c b From the midoint comutation, b d D Line to draw NE m v E Θ So: vd a( b c F(, /

Comuter Grahics Guta-Sroull algorithm (cont From the midoint algorithm, we had the decision variable (remember? d F( M F(, Going back to our revious equation: vd F(, a( b c a( b( / b / c F(, / b F( M b d b d d D Line to draw NE m E v Θ

Comuter Grahics So, Guta-Sroull algorithm (cont D d d d d And the denominator is constant Since we are blurring the line, we also need to comute the distances to oints and numerator numerator for for ( v d ( v d d vd d vd

Comuter Grahics Guta-Sroull algorithm (cont If the NE iel had been chosen: b F c b b a c b a F vd /, ( / / ( ( ( (, ( vd d d v vd d d v ( for numerator ( for numerator d d b d b M F b F ( /, (

Comuter Grahics Guta-Sroull algorithm (cont Comute midoint line algorithm, with the following alterations: At each iteration of the algorithm: If the E iel is chosen, set numerator d d If the NE iel is chosen, set numerator d d Udate d as in the regular algorithm Comute D numerator/denominator Color the current iel according to D Comute D uer (d-vd/denominator Comute D lower (dvd/denominator Color uer and lower accordingl