MIDPOINT CIRCLE & ELLIPSE GENERARTING ALGORITHMS

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.
APPLICATIONS OF INTEGRATION
Ellipse An ellipse is the set of points in a plane for which the sum of the distances from two fixed points is a given constant. The two fixed points.
Copyright © Cengage Learning. All rights reserved.
Section 11.6 – Conic Sections
Raster conversion algorithms for line and circle
INTEGRALS 5. INTEGRALS We saw in Section 5.1 that a limit of the form arises when we compute an area.  We also saw that it arises when we try to find.
Section 1.1 The Distance and Midpoint Formulas. x axis y axis origin Rectangular or Cartesian Coordinate System.
Chapter 3 Graphics Output Primitives
Circle Drawing algo..
Integration in polar coordinates involves finding not the area underneath a curve but, rather, the area of a sector bounded by a curve. Consider the region.
Solving Equations. Is a statement that two algebraic expressions are equal. EXAMPLES 3x – 5 = 7, x 2 – x – 6 = 0, and 4x = 4 To solve a equation in x.
Conic Sections. (1) Circle A circle is formed when i.e. when the plane  is perpendicular to the axis of the cones.
1 Preliminaries Precalculus Review I Precalculus Review II
Chapter 6 ADDITIONAL TOPICS IN TRIGONOMETRY. 6.1 Law of Sines Objectives –Use the Law of Sines to solve oblique triangles –Use the Law of Sines to solve,
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
Rectangular Coordinate Systems and Graphs of Equations René, René, he’s our man, If he can’t graph it, Nobody can.(2.1, 2.2)
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.
Larry F. Hodges 1 Design of Line and Circle Algorithms.
CHAPTER 9 CONIC SECTIONS.
Slide 5- 1 Copyright © 2006 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Unit #4 Conics. An ellipse is the set of all points in a plane whose distances from two fixed points in the plane, the foci, is constant. Major Axis Minor.
Slide 9- 1 Copyright © 2006 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
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)
ELLIPSE GENERATING ALGORITHMS 1. DEFINITION Ellipse is an elongated circle. Elliptical curves can be generated by modifying circle-drawing procedures.
Precalculus Fifth Edition Mathematics for Calculus James Stewart Lothar Redlin Saleem Watson.
WEEK 10 TRIGONOMETRIC FUNCTIONS TRIGONOMETRIC FUNCTIONS OF REAL NUMBERS; PERIODIC FUNCTIONS.
Section 7.3 – The Ellipse Ellipse – a set of points in a plane whose distances from two fixed points is a constant.
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.
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.
Midpoint Circle Algorithm
CS 325 Introduction to Computer Graphics 02 / 03 / 2010 Instructor: Michael Eckmann.
Polar Coordinates Lesson 6.3. Points on a Plane Rectangular coordinate system  Represent a point by two distances from the origin  Horizontal dist,
Instructor: Dr. Shereen Aly Taie If (P>0)
Today’s Date: 2/5/ Ellipses.
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.
Computer Graphics Inf4/MSc Computer Graphics Lecture 4 Line & Circle Drawing.
10/10/2006TCSS458A Isabelle Bichindaritz1 Line and Circle Drawing Algorithms.
Computer Graphics Lecture 07 Ellipse and Other Curves Taqdees A. Siddiqi
Computer Graphics Lecture 06 Circle Drawing Techniques Taqdees A. Siddiqi
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.
OUTPUT PRIMITIVES CEng 477 Computer Graphics METU, 2004.
Objectives Understand Bresenhams line drawing algorithm. Apply the algorithm to plot a line with the end points specified.
Primitive graphic objects
Scan Conversion or Rasterization
MID-POINT CIRCLE ALGORITHM
Scan Conversion or Rasterization
Lecture 05: Mid-point Ellipse algorithm Dr. Manal Helal – Fall 2014
Chapter Three Part I Output Primitives CS 380.
In this section, we will learn about: Using integration to find out
Scan Conversion of Circles
THE HYPERBOLA.
Scan Conversion (From geometry to pixels)
Chapter 3 Graphics Output Primitives
Presentation transcript:

MIDPOINT CIRCLE & ELLIPSE GENERARTING ALGORITHMS Circle Generating Algorithm Properties of circle Midpoint circle algorithm Ellipse-generating algorithm Properties of ellipse Midpoint ellipse algorithm VITS CSE

Circle Generating Algorithm Properties of Circle Circle is defined as the set of points that are all at a given distance r from a center point (xc,yc) For any circle point (x,y), the distance relationship is expressed by the Pythagorean theorem in Cartesian coordinate as: r yc ө (x,y) xc VITS CSE

Circle Generating Algorithm We could use this equation to calculate the points on a circle circumference by stepping along x-axis in unit steps from xc–r to xc+r and calculate the corresponding y values as VITS CSE

Circle Generating Algorithm The problems: Involves many computation at each stepi.e., square root and additions /subtractions Spacing between plotted pixel positions is not uniform Adjustment: interchanging x & y (step through y values and calculate x values) Involves many computation too! VITS CSE

Circle Generating Algorithm Another way: Calculate points along a circular boundary using polar coordinates r and ө x = xc + r cos ө y = yc + r sin ө Using fixed angular step size, a circle is plotted with equally spaced points along the circumference Problem: trigonometric calculations are still time consuming VITS CSE

Symmetry of Circles (8-way symmetry) Proposed Approach:symmetry of circles Shape of the circle is similar in each quadrant i.e. if we determine the curve positions in the 1st quadrant, we can generate the circle section in the 2nd quadrant of the xy plane (the 2 circle sections are symmetric with respect to the y axis) The circle section in the 3rd and 4th quadrant can be obtained by considering symmetry about the x axis One step further  symmetry between octants VITS CSE

8-way symmetry Circle sections in adjacent octants within 1 quadrant are symmetric with respect to the 45° line dividing the 2 octants Calculation of a circle point (x, y) in 1 octant yields the circle points for the other 7 octants 450 (y,x) (-y,x) (x,y) (x,-y) (y,-x) (-y,-x) (-x,-y) (-x,y) VITS CSE

Midpoint Circle Algorithm As in raster algorithm, we sample at unit intervals & determine the closest pixel position to the specified circle path at each step For a given radius, r and screen center position (xc,yc) , we can set up our algorithm to calculate pixel positions around a circle path centered at the coordinate origin (0,0) Each calculated position (x, y) is moved to its proper screen position by adding xc to x and yc to y VITS CSE

Midpoint Circle Algorithm Along a circle section from x=0 to x=y in the 1st quadrant, the slope (m) of the curve varies from 0 to -1.0 i.e. we can take unit steps in the +ve x direction over the octant & use decision parameter to determine which 2 possible positions is vertically closer to the circle path Positions in the other 7 octants are obtained by symmetry VITS CSE

Midpoint Circle Algorithm To apply the midpoint method, we define a circle function as fcirc(x,y) = x2 + y2 - r2 The relative positions of any point (x,y) can be determined by checking the sign of the circle function: < 0, if (x,y) is inside the circle boundary fcirc(x,y) = 0, if (x,y) is on the circle boundary > 0, if (x,y) is outside the circle boundary VITS CSE

Midpoint Circle Algorithm Consider current position (xk, yk) next pixel position is either(xk+1, yk) or (xk+1, yk-1)? xk yk xk+1 xk+2 yk-1 Circle path Midpoint VITS CSE

Midpoint Circle Algorithm Our decision parameter is the earlier circle function evaluated at the mid point between the 2 pixels < 0: midpoint is inside the circle; plot (xk+1, yk) +ve: midpoint is outside the circle; plot (xk+1, yk-1) Successive decision parameters are obtained using incremental calculation pk VITS CSE

Midpoint Circle Algorithm To ensure things are as efficient as possible we can do all of our calculations incrementally First consider: or where yk+1 is either yk or yk-1 depending on the sign of pk VITS CSE

Midpoint Circle Algorithm Initial decision parameter is obtained by evaluating the circle function at the start position (x0, y0) = (0,r) p0 = f(1, r–1/2) = 12 + (r – 1/2)2 – r2 p0 = 5/4 – r If the radius is specified as an integer, we can simple round p0 to p0 = 1 – r Then if pk < 0 then the next decision variable is given as: If pk > 0 then the decision variable is: VITS CSE

Midpoint Circle Algorithm Input radius, r, and circle center (xc, yc), then set the coordinates for the 1st point on the circumference of a circle centered at the origin as (x0, y0) = (0,r) Calculate initial value of decision parameter: At each xk, starting at k = 0, test the value of pk : If pk < 0, next point will be (xk+1, yk) and else, next point will be (xk+1, yk – 1) and   where 2xk+1 = 2xk + 2 and 2yk+1 = 2yk – 2 Determine symmetry points in the other 7 octants. Get the actual point for circle centered at (xc,yc) that is (x+xc, y+yc). Repeat step 3 to 5 until x  y. VITS CSE

Try this out! Given a circle radius r=10, demonstrate the midpoint circle algorithm by determining positions along the circle octant in the 1st quadrant p0 = ? (x0,y0) = ? k pk (xk+1,yk+1) 2xk+1 2yk+1 1 2 3 4 5 6 VITS CSE

Plot pixel positions 10 9 8 7 6 5 4 3 2 1 VITS CSE

Try this again! Given a circle with r=8, calculate each pixel positions along the circumference at the 2nd quadrant VITS CSE

Ellipse Generating Algorithm Ellipse – an elongated circle. A modified circle whose radius varies from a maximum value in one direction to a minimum value in the perpendicular direction. A precise definition in terms of distance from any point on the ellipse to two fixed position, called the foci of the ellipse. The sum of these two distances is the same value for all points on the ellipse. P=(x,y) F2 F1 d2 d1 VITS CSE

Ellipse Generating Algorithm If the distance of the two focus positions from any point P=(x, y) on the ellipse are labeled d1 and d2, the general equation of an ellipse: d1 + d2 = constant Expressing distance d1 and d2 in terms of the focal coordinates F1=(x1, y1) and F2=(x2, y2), we have VITS CSE

Ellipse Generating Algorithm However, we will only consider ‘standard’ ellipse: ry xc rx yc VITS CSE

2-way symmetry An ellipse only has a 2-way symmetry. (x,y) (-x,y) ry rx ry VITS CSE

Equation of an ellipse Consider an ellipse centered at the origin, (xc,yc)=(0,0): Ellipse function …and its properties: fellipse(x,y) < 0 if (x,y) is inside the ellipse fellipse(x,y) = 0 if (x,y) is on the ellipse fellipse(x,y) > 0 if (x,y) is outside the ellipse VITS CSE

Midpoint Ellipse Algorithm Ellipse is different from circle. Similar approach with circle, different in sampling direction. Slope of ellipse is: dy/dx = - 2ry2x/2rx2y Region 1: Sampling is at x direction Choose between (xk+1, yk), or (xk+1, yk-1) Move of region 1 if 2r2yx >= 2r2xy Region 2: Sampling is at y direction Choose between (xk, yk-1), or (xk+1, yk-1) Slope = -1 Region 1 Region 2 ry rx VITS CSE

Decision parameters Region 1: Decision parameter p1k < 0: midpoint is inside choose pixel (xk+1, yk)   p1k >= 0: midpoint is outside/on choose pixel (xk+1, yk-1) Region 2: Decision parameter   p2k <= 0: midpoint is inside/on choose pixel (xk+1, yk-1) p2k > 0: midpoint is outside choose pixel (xk, yk-1) VITS CSE

Midpoint Ellipse Algorithm Input rx, ry and ellipse center (xc, yc). Obtain the first point on an ellipse centered on the origin (x0, y0) = (0, ry). Calculate initial value for decision parameter in region 1 as: At each xk in region 1, starting from k = 0, test p1k :   If p1k < 0, next point (xk+1, yk) and else, next point (xk+1, yk-1) and   with 2ry2xk+1 = 2ry2xk + 2ry2, 2rx2yk+1 = 2rx2yk – 2rx2 and repeat step 1 to 3 until 2ry2x  2rx2y   VITS CSE

Midpoint Ellipse Algorithm Initial value for decision parameter in region 2: where (x0, y0) is the last position calculate in region 1 5. At each yk in region 2, starting from k = 0, test p2k:   If p2k > 0, next point is (xk, yk-1) and else, next point is (xk+1, yk-1) and   continue until y=0 VITS CSE

Midpoint Ellipse Algorithm For both region determine symmetry points in the other 3 quadrants Move each calculated pixel position (x,y) onto the elliptical path centered on (xc,yc) and plot the coordinate values x=x + xc, y =y + yc   VITS CSE

Try this out! k p1k (xk+1,yk+1) 2ry2 xk+1 2 rx2yk+1 -332 (1,6) 72 768 1 -224 (2,6) 144 2 -44 (3,6) 216 3 208 (4,5) 288 640 4 -108 (5,5) 360 5 (6,4) 432 52 6 244 (7,3) 504 384 Given input ellipse parameter rx=8 and ry=6, determine pixel positions along the ellipse path in the first quadrant using the midpoint ellipse algorithm 2ry2x = ? 2rx2y = 2rx2ry = ? p10 = ? We now move out from R1 since2ry2 x> 2 rx2y For R2,initial point is(xo,yo)=(7,3)& p2o=f(7+1/2,2)=-151 k p2k (xk+1,yk+1) 2rv2 xk+1 2 rx2yk+1 -151 (8,2) 576 256 1 233 (8,1) 128 2 745 (8,0) -- VITS CSE

Plot pixel positions 6 5 4 3 2 1 7 8 VITS CSE