MODULE - 4. e-pg Pathshala

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

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

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

UNIT 2 GRAPHIC PRIMITIVES

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

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

Chapter - 2: Geometry and Line Generations

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

Computer Graphics: Graphics Output Primitives Line Drawing Algorithms

Digital Differential Analyzer Bresenhams Line Drawing Algorithm

WHAT YOU SHOULD LEARN

Test Name: Chapter 3 Review

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

Output Primitives Lecture: 4. Lecture 4

Section 1.1 The Distance and Midpoint Formulas

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

CPSC / Scan Conversion

CSCI 4620/8626. Coordinate Reference Frames

(Refer Slide Time: 00:03:51)

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

Rasterization: Geometric Primitives

GRAPHICS OUTPUT PRIMITIVES

Computer Graphics D Graphics Algorithms

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

CS 130. Scan Conversion. Raster Graphics

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

Overview of Computer Graphics

Line Drawing Week 6, Lecture 9

Graphs of Equations. MATH 160, Precalculus. J. Robert Buchanan. Fall Department of Mathematics. J. Robert Buchanan Graphs of Equations

UNIT -8 IMPLEMENTATION

MODULE - 7. Subject: Computer Science. Module: Other 2D Transformations. Module No: CS/CGV/7

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

CS6504 & Computer Graphics Unit I Page 1

SE Mock Online Test 1-CG

From Ver(ces to Fragments: Rasteriza(on

Review for Mastery Using Graphs and Tables to Solve Linear Systems

MODULE - 9. Subject: Computer Science. Module: Line Clipping. Module No: CS/CGV/9

SNAP Centre Workshop. Graphing Lines

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

Unit 2 Output Primitives and their Attributes

Chapter 8: Implementation- Clipping and Rasterization

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

Graphics (Output) Primitives. Chapters 3 & 4

RASTERIZING POLYGONS IN IMAGE SPACE

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

Lecture 5. If, as shown in figure, we form a right triangle With P1 and P2 as vertices, then length of the horizontal

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

Einführung in Visual Computing

Computer Graphics D Graphics Algorithms

Chapter 3. Sukhwinder Singh

Line Drawing. Foundations of Computer Graphics Torsten Möller

Section 18-1: Graphical Representation of Linear Equations and Functions

Chapter 1. Linear Equations and Straight Lines. 2 of 71. Copyright 2014, 2010, 2007 Pearson Education, Inc.

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

1 Introduction to Graphics

WK # Given: f(x) = ax2 + bx + c

Efficient Plotting Algorithm

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

Chapter 3A Rectangular Coordinate System

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

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

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

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

Section Graphs and Lines

Topic #1: Rasterization (Scan Conversion)

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

A New Line Drawing Algorithm Based on Sample Rate Conversion

Solution Notes. COMP 151: Terms Test

Scan Converting Circles

We have already studied equations of the line. There are several forms:

notes13.1inclass May 01, 2015

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

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

Module 4. Stereographic projection: concept and application. Lecture 4. Stereographic projection: concept and application

Rendering. A simple X program to illustrate rendering

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

State the domain and range of the relation. EX: {(-1,1), (1,5), (0,3)} 1 P a g e Province Mathematics Southwest TN Community College

We have already studied equations of the line. There are several forms:

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

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

EFFICIENT INTEGER ALGORITHMS FOR THE GENERATION OF CONIC SECTIONS

4. TANGENTS AND NORMALS

9.1 Parametric Curves

A function: A mathematical relationship between two variables (x and y), where every input value (usually x) has one output value (usually y)

Computer Graphics Lecture Notes

MET71 COMPUTER AIDED DESIGN

6.7. POLAR COORDINATES

CSC Computer Graphics

Scan Conversion. Lines and Circles

Painter s HSR Algorithm

An Improved Algorithm for Scan-converting a Line

Example 1: Give the coordinates of the points on the graph.

Raster Scan Displays. Framebuffer (Black and White)

Scan Conversion. Drawing Lines Drawing Circles

Investigating the Sine and Cosine Functions Part 1

CS Rasterization. Junqiao Zhao 赵君峤

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

Computer Graphics: 8-Hidden Surface Removal

L13-Mon-3-Oct-2016-Sec-1-1-Dist-Midpt-HW Graph-HW12-Moodle-Q11, page 1 L13-Mon-3-Oct-2016-Sec-1-1-Dist-Midpt-HW Graph-HW12-Moodle-Q11

Rational Numbers on the Coordinate Plane. 6.NS.C.6c

Transcription:

e-pg Pathshala MODULE - 4 Subject : Computer Science Paper: Computer Graphics and Visualization Module: Midpoint Circle Drawing Procedure Module No: CS/CGV/4 Quadrant 1 e-text Before going into the Midpoint circle drawing procedure, Lets solve an example problem, to understand how Bresenham s procedure works for various lines. Consider examples as below. Example Problem -1: (When m <=1 and m is +ve) Problem: Scan convert the line between (2, 2) and (10, 5) using Bresenham s algorithm Sol: Since the line has a slope m=3/8 =0.375 the following set of equations would be valid P 0 =2 y- x, y=3, x=8 P 0 =6-8=-2 Represent first pixel as (X 0,Y 0 ) =(2,2). P 0 =-2, since, P 0 ve use case (i) i.e. next pixel is (X 1,Y 1 ) =(X 0 +1,Y 0 )=(3,2) and Compute P 1 =P 0 +2*3 = -2+6=4, P 1 +ve use case (ii) K P k X k+1 Y K+1 0-2 3 2 1 4 4 3 2-6 5 3 3 0 6 4 4-10 7 4 5-4 8 4 6 2 9 5 Example Problem -2: (When m <=1 and m is -ve) Problem: Scan convert the line between (2, 8) and (10, 5) using Bresenham s algorithm Sol: y = -3, x = 8

Since the line has a slope m=-3/8=-0.375 i.e. m <1 the same set of equations used for the previous example would be valid. P 0 =2 y - x y =3 x =8 P 0 =6-8=-2 Represent first pixel as (X 0,Y 0 ) =(2,8) P 0 =-2 use case (i) i.e. next pixel is (X 1,Y 1 )=(X 0 +1,Y 0 )=(3,8) and compute P 1 =P 0 +2*3 = -2+6=4 Since P 1 is +ve use case (ii) so next pixel to be plotted is (4,7) P 2 =4+2x3-2x8 = -6 Since P 2 is ve, the next pixel to be plotted is (5, 7) and continue till we reach the end of line. K P k X k+1 Y K+1 0-2 3 8 1 4 4 7 2-6 5 7 3 0 6 6 4-10 7 6 5-4 8 6 6 2 9 5 Note that even if y is ve, we consider only the magnitude for all computations Observe that while x is increasing in increments of 1 from 3 to 9, while y is decreasing from 8 to 5 as per the algorithm. Conclusion: Important observation while working with negative slopes is that do always compute magnitudes for Δx and Δy i.e. Δx and Δy and never consider signs. Observe always that P k should fluctuate about +ve and -ve For Longer lines DDA line drifts away from the true line. Bresenham s line fluctuates about the theoretical line. Bresenham s line better approximates the theoretical line i.e., it never deviates from the theoretical line. No floating point calculations are involved.

Summary: Outlined the Bresenham s line drawing procedure Noted the advantages of the procedure over DDA procedure. Midpoint Circle Drawing Procedure: We have started with the first primitive, points, followed by lines, now followed by the third primitive of interest, the circle. A circle is fundamentally symmetric and exhibits octant symmetry. i.e. a circle is symmetric about its octants. If we know a point on any one of the octants the remaining 7 symmetric points can be plotted by interchanging magnitudes of x and y and also signs Lets try to understand what octant symmetry is through the following diagram. As shown in the diagram above, divide the circle into 8 parts (each is an octant) using 4 axes. Assume that we know a point say (2, 7) on one of the octants, the remaining 7 symmetric points on the seven octants can be easily plotted without making any computations. If we fold the octants about an axis, the octant exactly overlaps on the neighbouring octant due to symmetry. It is enough that we compute points on one of the octants. The remaining points can be easily plotted without any computations. Assuming the circle is centered at origin and has a radius r units, the algorithm can start with a known point (0, r) and proceed to compute points till the end of the octant is reached. For convenience, we shall chose the first octant i.e. that octant in which the relation x<y is satisfied. We need to compute points on part of the circle shown in the diagram. How do we know where to stop so that the end of the octant is reached? We need to find out the stopping condition for the algorithm. The?? Symbols shown in the diagram represent the last

point on the chosen octant at which we should stop. Moreover the point (??) might lie on the axis which satisfies the equation, x=y, that means all points that lie on that axis are like, (2,2) (3,3) and so on. This axis divides the first positive quadrant into two zones or two octants. All points on the upper side of the axis satisfy the relation x<y, while all the points on the lower side of the axis satisfy the relation x>y. That is to fix our stopping condition as we go on computing points, it is just sufficient that we check the relation between x and y, i.e., as long as x<=y we can do our computation, and stop when the relation x<=y is not satisfied by the points. Also observe that in the chosen octant, while we proceed to compute points on the circle boundary, the slope of the circle changes from 0 (positive) to -1 (negative). While x increases, y decreases. Because the circle has slope that is almost flat, we can sample the circle along x-axis at unit steps and compute the corresponding y-values. Start at (0,r) End at (x,y) such that x>=y i.e. whenever x becomes >=y we can stop the algo. Because the shape of the circle in this region is more flat, we can sample it along X- axis at unit intervals, and compute the corresponding y-values. What is the principle behind Midpoint Circle drawing procedure? Equation of circle with centre at origin, and having a radius of r units is given by x 2 +y 2 =r 2. We can start with a known point on the circle say (x k,y k ) in the chosen octant. Let the next point to be computed be represented as (x k+1,y k+1 ). Since we are sampling on x-axis at unit x-intervals, it is evident that the next x, x k+1 = x k +1. As we know from theory that any point x, y that satisfy the relation x 2 +y 2 -r 2 <0 is a point that lies inside the circle boundary x 2 +y 2 -r 2 >0 is a point that lies outside the circle boundary x 2 +y 2 -r 2 =0 is a point that lies on the circle boundary

For the next x position x k +1, we can choose between two y positions y k or y k -1. Compute midpoint for the two possible pixel locations (x k +1, y k ) (x k +1, y k -1) and verify its position relative to the circle boundary. If the midpoint lies inside the circle boundary choose to plot the upper pixel else the lower pixel. The coordinates of the midpoint are for the two possible pixels positions (x k +1, y k ) or (x k +1, y k -1) are (x k + 1, y k 1 2 ) Now by substituting the coordinates of the midpoint, in the circle equation, we can check whether the midpoint lies inside, outside or on the circle boundary. Thus the decision parameter P k for our derivation is given by P k = (x k + 1) 2 + (y k 1 2 )2 r 2 i.e., P k <0, means that midpoint is inside the circle boundary, so the circle boundary is close to the upper pixel, thus choose the upper pixel (x k +1, y k ) for plotting, otherwise if P k >0, the midpoint is outside the circle boundary, so the circle boundary is close to the lower pixel, thus choose the lower pixel (x k +1, y k -1) for plotting, or otherwise if P k =0, the midpoint lies on the circle boundary, so we can choose between either of upper and lower pixels and so for consistency we can choose the upper pixel, for this case. Case (i): If P k <0 midpoint is inside the circle boundary and choose the upper pixel (x k +1, y k ) i.e. y k+1 =y k and Case (ii): If P k >=0 midpoint is outside the circle boundary and choose the lower pixel (x k +1, y k -1) i.e. y k+1 =y k -1 and

To compute the initial decision parameter, P 0 use the following eq. The initial point (x 0,y 0 )=(0,r) Problem: Find the points on a circle on of its octants with the circle centered at (5,5) and has a radius of 8 units. Solution: Assume that the circle is centered at origin and proceed to solve. After finding the points add center (5, 5) to each point. The initial point (x 0,y 0 )=(0,8) P 0 = 1-r = 1-8=-7 (x 0,y 0 ) = (0, 8) P 0 =-7 P 1 =-7+2+1=-4 (-ve, case (i)) P 2 =-4+4+1=1 (+ve, case (ii)) P 3 =1+6-14+1=-6 (-ve, case (i))

Conclusion: Midpoint circle drawing algorithm is more efficient, due to o o o Recursive nature of the algorithm No floating point calculations Accurate and simple