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

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

Computer Graphics Lecture Notes

Overview of Computer Graphics

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

MODULE - 4. e-pg Pathshala

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

GRAPHICS OUTPUT PRIMITIVES

UNIT 2 GRAPHIC PRIMITIVES

CSC Computer Graphics

Rasterization: Geometric Primitives

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

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

Output Primitives Lecture: 4. Lecture 4

CPSC / Scan Conversion

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

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

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

(Refer Slide Time: 00:03:51)

Digital Differential Analyzer Bresenhams Line Drawing Algorithm

Unit 2 Output Primitives and their Attributes

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

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

Computer Graphics: Graphics Output Primitives Line Drawing Algorithms

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

UNIT -8 IMPLEMENTATION

Scan Conversion. Drawing Lines Drawing Circles

From Ver(ces to Fragments: Rasteriza(on

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

Chapter 3. Sukhwinder Singh

(Refer Slide Time: 00:02:00)

CSC Computer Graphics

Chapter 8: Implementation- Clipping and Rasterization

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

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

1.8 Coordinate Geometry. Copyright Cengage Learning. All rights reserved.

Advantages: Disadvantages: Q.1 Explain raster scan display with its advantages and disadvantages?

CSCI 4620/8626. Coordinate Reference Frames

CS6504 & Computer Graphics Unit I Page 1

Efficient Plotting Algorithm

I Internal Examination (Model Paper) B.Tech III Year VI semester, Computer Science & Engineering

WHAT YOU SHOULD LEARN

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

Line Drawing. Foundations of Computer Graphics Torsten Möller

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

1 Introduction to Graphics

SE Mock Online Test 1-CG

Unit 1, Lesson 1: Moving in the Plane

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

Rasterization and Graphics Hardware. Not just about fancy 3D! Rendering/Rasterization. The simplest case: Points. When do we care?

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

Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

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

Line Drawing Week 6, Lecture 9

CS 543: Computer Graphics. Rasterization

Computer Graphics: 6-Rasterization

(Refer Slide Time: 9:36)

CS 130. Scan Conversion. Raster Graphics

Raster Scan Displays. Framebuffer (Black and White)

Einführung in Visual Computing

Chapter - 2: Geometry and Line Generations

Computer Graphics D Graphics Algorithms

Topic #1: Rasterization (Scan Conversion)

Graphics (Output) Primitives. Chapters 3 & 4

Computer Graphics: Line Drawing Algorithms

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

Computer Graphics. - Rasterization - Philipp Slusallek

RASTERIZING POLYGONS IN IMAGE SPACE

Section 1.1 The Distance and Midpoint Formulas

Institutionen för systemteknik

Review for Mastery Using Graphs and Tables to Solve Linear Systems

Mini-Project 1: The Library of Functions and Piecewise-Defined 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

Math 8 Honors Coordinate Geometry part 3 Unit Updated July 29, 2016

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

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

Three-Dimensional Coordinate Systems

Prof. Feng Liu. Fall /25/2018

The x coordinate tells you how far left or right from center the point is. The y coordinate tells you how far up or down from center the point is.

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

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

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

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

Scan Converting Circles

CS 4731/543: Computer Graphics Lecture 7 (Part I): Raster Graphics: Polygons & Antialiasing. Emmanuel Agu

For this assignment, you are to implement three line drawers and a polygon drawer.

The Ultimate Maths Vocabulary List

CS Rasterization. Junqiao Zhao 赵君峤

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

Chapter 3A Rectangular Coordinate System

Computer Graphics 7 - Rasterisation

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

Pipeline implementation II

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

COMP371 COMPUTER GRAPHICS

1-1. Points, Lines, and Planes. Lesson 1-1. What You ll Learn. Active Vocabulary

(Refer Slide Time: 0:32)

Lossy Coding 2 JPEG. Perceptual Image Coding. Discrete Cosine Transform JPEG. CS559 Lecture 9 JPEG, Raster Algorithms

GCSE LINKED PAIR PILOT 4363/02 METHODS IN MATHEMATICS UNIT 1: Methods (Non-Calculator) HIGHER TIER

Transcription:

Drawing Circles In today s lecture we ll have a look at: Circle drawing algorithms A simple technique The mid-point circle algorithm Polygon fill algorithms Summary raster drawing algorithms

A Simple Circle Drawing Algorithm The equation for a circle is: where r is the radius the circle x So, we can write a simple circle drawing algorithm by solving the equation for y at unit x intervals using: y r y r x

3 A Simple Circle Drawing Algorithm (cont ) y0 0 0 0 y 0 0 y 0 0 y9 0 9 6 y0 0 0 0

4 A Simple Circle Drawing Algorithm (cont ) However, unsurprisingly this is not a brilliant solution! Firstly, the resulting circle has large gaps where the slope approaches the vertical Secondly, the calculations are not very efficient The square (multiply) operations The square root operation try really hard to avoid these! We need a more efficient, more accurate solution

5 Eight-Way Symmetry The first thing we can notice to make our circle drawing algorithm more efficient is that circles centred at (0, 0) have eight-way symmetry (-x, y) (x, y) (-y, x) (y, x) (-y, -x) R (y, -x) (-x, -y) (x, -y)

6 Mid-Point Circle Algorithm Similarly to the case with lines, there is an incremental algorithm for drawing circles the mid-point circle algorithm In the mid-point circle algorithm we use eight-way symmetry so only ever calculate the points for the top right eighth a circle, and then use symmetry to get the rest the points The mid-point circle algorithm was developed by Jack Bresenham, who we heard about earlier. Bresenham s patent for the algorithm can be viewed here.

7 Mid-Point Circle Algorithm (cont ) Assume that we have just plotted point (x k, y k ) (x k, y k ) (x k +, y k ) The next point is a choice between (x k +, y k ) and (x k +, y k -) (x k +, y k -) We would like to choose the point that is nearest to the actual circle So how do we make this choice?

8 Mid-Point Circle Algorithm (cont ) Let s re-jig the equation the circle slightly to give us: ( x, y) x y r f circ The equation evaluates as follows: f circ 0, if ( x, y) 0, if 0, if ( x, y) is inside ( x, y) is the circle boundary on the circle boundary ( x, y) is outside the circle boundary By evaluating this function at the midpoint between the candidate pixels we can make our decision

9 Mid-Point Circle Algorithm (cont ) Assuming we have just plotted the pixel at (x k,y k ) so we need to choose between (x k +,y k ) and (x k +,y k -) Our decision variable can be defined as: p k fcirc ( xk, yk ) ( xk ) ( yk ) r If p k < 0 the midpoint is inside the circle and and the pixel at y k is closer to the circle Otherwise the midpoint is outside and y k - is closer

0 Mid-Point Circle Algorithm (cont ) To ensure things are as efficient as possible we can do all our calculations incrementally First consider: or: p k p k f circ [( x k x k, y ) ] where y k+ is either y k or y k - depending on the sign p k k y r k pk ( xk ) ( yk yk ) ( yk yk )

Mid-Point Circle Algorithm (cont ) The first decision variable is given as: Then if p k < 0 then the next decision variable is given as: If p k > 0 then the decision variable is: r r r r f p circ 4 5 ) ( ) (, 0 k k k x p p k k k k y x p p

The Mid-Point Circle Algorithm MID-POINT CIRCLE ALGORITHM Input radius r and circle centre (x c, y c ), then set the coordinates for the first point on the circumference a circle centred on the origin as: ( 0 x0, y ) (0, r) Calculate the initial value the decision parameter as: p 0 5 4 Starting with k = 0 at each position x k, perform the following test. If p k < 0, the next point along the circle centred on (0, 0) is (x k +, y k ) and: p r k pk xk

3 The Mid-Point Circle Algorithm (cont ) Otherwise the next point along the circle is (x k +, y k -) and: p k pk xk yk 4. Determine symmetry points in the other seven octants 5. Move each calculated pixel position (x, y) onto the circular path centred at (x c, y c ) to plot the coordinate values: x x x c y y 6. Repeat steps 3 to 5 until x >= y yc

4 Mid-Point Circle Algorithm Example To see the mid-point circle algorithm in action lets use it to draw a circle centred at (0,0) with radius 0

5 Mid-Point Circle Algorithm Example (cont ) 0 k p k (x k+,y k+ ) x k+ y k+ 9 8 7 6 5 4 3 0 0 3 4 5 6 7 8 9 0 0 3 4 5 6

6 Mid-Point Circle Algorithm Exercise Use the mid-point circle algorithm to draw the circle centred at (0,0) with radius 5

7 Mid-Point Circle Algorithm Example (cont ) 6 5 4 3 0 9 8 7 6 5 4 3 0 0 3 4 5 6 7 8 9 0 34 56 k p k (x k+,y k+ ) x k+ y k+ 0 3 4 5 6 7 8 9 0

8 Mid-Point Circle Algorithm Summary The key insights in the mid-point circle algorithm are: Eight-way symmetry can hugely reduce the work in drawing a circle Moving in unit steps along the x axis at each point along the circle s edge we need to choose between two possible y coordinates

9 Filling Polygons So we can figure out how to draw lines and circles How do we go about drawing polygons? We use an incremental algorithm known as the scan-line algorithm

0 Scan-Line Polygon Fill Algorithm 0 Scan Line 8 6 4 0 4 6 8 0 4 6

Scan-Line Polygon Fill Algorithm The basic scan-line algorithm is as follows: Find the intersections the scan line with all edges the polygon Sort the intersections by increasing x coordinate Fill in all pixels between pairs intersections that lie interior to the polygon

Scan-Line Polygon Fill Algorithm (cont )

3 Line Drawing Summary Over the last couple lectures we have looked at the idea scan converting lines The key thing to remember is this has to be FAST For lines we have either DDA or Bresenham For circles the mid-point algorithm

4 Anti-Aliasing

5 Summary Of Drawing Algorithms

6 Mid-Point Circle Algorithm (cont ) 6 5 4 3 3 4

7 Mid-Point Circle Algorithm (cont ) M 6 5 4 3 3 4

8 Mid-Point Circle Algorithm (cont ) M 6 5 4 3 3 4

9 Blank Grid

30 Blank Grid

3 Blank Grid 0 9 8 7 6 5 4 3 0 0 3 4 5 6 7 8 9 0

3 Blank Grid