Instructor: Dr. Shereen Aly Taie 1. 2 3 4 5 6 If (P>0)

Slides:



Advertisements
Similar presentations
Circle Drawing Asst. Prof. Dr. Ahmet Sayar Kocaeli University
Advertisements

Contents In today’s lecture we’ll have a look at:
CS 450: COMPUTER GRAPHICS DRAWING ELLIPSES AND OTHER CURVES SPRING 2015 DR. MICHAEL J. REALE.
CS 376 Introduction to Computer Graphics 02 / 02 / 2007 Instructor: Michael Eckmann.
Computer Graphics 4: Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling By:Kanwarjeet Singh.
CS 450: COMPUTER GRAPHICS REVIEW: DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
+ CPCS 391 Computer Graphics 1 Instructor: Dr. Sahar Shabanah Lecture 3.
Larry F. Hodges (modified by Amos Johnson) 1 Design of Line, Circle & Ellipse Algorithms.
Lecture 17 Fun with Graphics Dr. Dimitrios S. Nikolopoulos CSL/UIUC.
Lecture 16 Fun with graphics
2D Output Primitives Graphics packages provide basic operations (called primitive operations) to describe a scene in terms of geometric structures. The.
Raster conversion algorithms for line and circle
Rasterization Foley, Ch: 3. Pixels are represented as disjoint circles centered on uniform grid Each (x,y) of the grid has a pixel Y X (1,1) (1,2) (0,0)
Section 1.1 The Distance and Midpoint Formulas. x axis y axis origin Rectangular or Cartesian Coordinate System.
CS 450: COMPUTER GRAPHICS DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
Circle Drawing algo..
Graph an equation in standard form
CGMB214: Introduction to Computer Graphics
1 CS 430/536 Computer Graphics I Circle Drawing and Clipping Week 3, Lecture 6 David Breen, William Regli and Maxim Peysakhov Geometric and Intelligent.
Dr. S.M. Malaek Assistant: M. Younesi
WHERE TO DRAW A LINE?? Line drawing is accomplished by calculating intermediate positions along the line path between specified end points. Precise definition.
Scan Conversion Line and Circle
CS 450: COMPUTER GRAPHICS REVIEW: DRAWING ELLIPSES AND OTHER CURVES SPRING 2015 DR. MICHAEL J. REALE.
Distance and Midpoint Graphing, Symmetry, Circles Solving.
Introduction This chapter gives you several methods which can be used to solve complicated equations to given levels of accuracy These are similar to.
Larry F. Hodges 1 Design of Line and Circle Algorithms.
10/15/02 (c) 2002 University of Wisconsin, CS559 Last Time Clipping.
1 Circle Drawing Algorithms Pictures snagged from
Introduction Computer Graphics & Its application Types of computer graphics Graphic display : random Scan & Raster Scan display Frame buffer and video.
Graphics Output Primitives
 A line segment in a scene is defined by the coordinate positions of the line end-points x y (2, 2) (7, 5)
MIDPOINT CIRCLE & ELLIPSE GENERARTING ALGORITHMS
November 18, We could solve for y in terms of x ( x 0, y 0 ) are the origin points A Simple Circle Drawing Algorithm The equation for a circle.
ACTIVITY 41 Review For Final Problem 17 Evaluate the expression:
10/15/02 (c) 2002 University of Wisconsin, CS559 Who Am I? Prof Stephen Chenney These notes will be online after the lecture – in fact they’re online already.
10/19/04© University of Wisconsin, CS559 Fall 2004 Last Time Clipping –Why we care –Sutherland-Hodgman –Cohen-Sutherland –Intuition for Liang-Barsky Homework.
Circles Students will be able to transform an equation of a circle in standard form to center, radius form by using the complete the square method.
Midpoint Circle Algorithm
CS 325 Introduction to Computer Graphics 02 / 03 / 2010 Instructor: Michael Eckmann.
GEOMETRY AND LINE GENERATION Geometry and Line Generation Chapter 2.
Notes 2.1 and 2.2 LOOKING FOR SQUARES AND SQUARE ROOTS.
The standard form of the equation of a circle with its center at the origin is Notice that both the x and y terms are squared. Linear equations don’t.
Curves & circles. Write down a possible equation that this could represent y = 6 – 3x or y = -3x + 6.
7.7 Inverse Relations and Functions. Using a graphing calculator, graph the pairs of equations on the same graph. Sketch your results. Be sure to use.
Bresenham’s Line Algorithm
Computer Graphics : Bresenham Line Drawing Algorithm, Circle Drawing
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Write Bresenham’s algorithm for generation of line also indicate which raster locations would be chosen by Bresenham’s algorithm when scan converting.
Warm up State the domain and range for: If f(x) = x 3 – 2x +5 find f(-2)
Computer Graphics Lecture 07 Ellipse and Other Curves Taqdees A. Siddiqi
Computer Graphics Lecture 06 Circle Drawing Techniques Taqdees A. Siddiqi
Rasterization, or “What is glBegin(GL_LINES) really doing?” Course web page: February 23, 2012  Lecture 4.
Line Drawing Algorithms 1. A line in Computer graphics is a portion of straight line that extends indefinitely in opposite direction. 2. It is defined.
Objectives Understand Bresenhams line drawing algorithm. Apply the algorithm to plot a line with the end points specified.
Primitive graphic objects
MID-POINT CIRCLE ALGORITHM
§ 1.3 Intercepts.
Since all points on the x-axis have a y-coordinate of 0, to find x-intercept, let y = 0 and solve for x Since all points on the y-axis have an x-coordinate.
Quick Graphs of Linear Equations
CS G140 Graduate Computer Graphics
Lecture 05: Mid-point Ellipse algorithm Dr. Manal Helal – Fall 2014
Chapter Three Part I Output Primitives CS 380.
Scan Conversion of Circles
Rasterization and Antialiasing
Graphing Linear Equations
Rasterization and Antialiasing
Notes Over 9.1 Finding Square Roots of Numbers
Chapter 3 Graphics Output Primitives
Chapter 1 Test Review.
Presentation transcript:

Instructor: Dr. Shereen Aly Taie 1

2

3

4

5

6 If (P>0)

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

However, unsurprisingly this is not a brilliant solution! circle has large gaps Firstly, the resulting circle has large gaps where the slope approaches the vertical calculations are not very efficient 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

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) (y, x) (y, -x) (x, -y)(-x, -y) (-y, -x) (-y, x) (-x, y)

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 of a circle  Then use symmetry to get the rest of the points.

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

Let’s re-jig the equation of the circle slightly to give us: The equation evaluates as follows: y evaluating this function at the midpoint between the candidate pixels we can make our decision

Assuming we have just plotted the pixel at ( x k,y k ) so we need to choose between ( x k +1,y k ) and ( x k +1,y k -1 ) Our decision variable can be defined as: inside y k is closer If p k < 0 the midpoint is inside the circle and and the pixel at y k is closer to the circle outside y k -1 is closer Otherwise the midpoint is outside and y k -1 is closer

To ensure things are as efficient as possible we can do all of our calculations incrementally First consider: or: where y k+1 is either y k or y k -1 depending on the sign of p k

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:

17

18

To see the mid-point circle algorithm in action lets use it to draw a circle centred at (0,0) with radius 10

20 If p k < 0 If p k < 0, the next point along the circle centred on (0, 0) is (x k +1, y k ) and: Otherwise next point (x k +1, y k -1) Otherwise the next point along the circle is (x k +1, y k -1) and:

kpkpk (x k+1,y k+1 ) 2x k+1 2y k

Use the mid-point circle algorithm to draw the circle centred at (0,0) with radius 16

kpkpk (x k+1,y k+1 ) 2x k+1 2y k

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