Write Bresenham’s algorithm for generation of line also indicate which raster locations would be chosen by Bresenham’s algorithm when scan converting.

Slides:



Advertisements
Similar presentations
Contents In today’s lecture we’ll have a look at:
Advertisements

Graphics Primitives Part II: Bresenhams line and circle.
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.
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphics Drawing Elementary Figures Dr. Eng. Farag Elnagahy.
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.
Line Drawing Algorithms. Rasterization-Process of determining which pixels give the best approximation to a desired line on the screen. Scan Conversion-Digitizing.
COMPUTER GRAPHICS 2D TRANSFORMATIONS.
30/9/2008Lecture 21 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD3107 University of Palestine.
Raster conversion algorithms for line and circle
Graphics Output Primitives Pixel Addressing and Fill Area Dr. M. Al-Mulhem Feb. 1, 2008.
Line Drawing by Algorithm. Line Drawing Algorithms Line drawn as pixels Graphics system –Projects the endpoints to their pixel locations in the frame.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Scan Conversion CS123 1 of 44Scan Conversion - 10/14/2014.
CS 450: COMPUTER GRAPHICS DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
Circle Drawing algo..
Computer Graphics- SCC 342
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
Graphics Primitives: line. Pixel Position
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
Transformation of Graphics
Informationsteknologi Monday, November 26, 2007Computer Graphics - Class 121 Today’s class Drawing lines Bresenham’s algorithm Compositing Polygon filling.
2D Transformation of Graphics
CS 325 Introduction to Computer Graphics 02 / 01 / 2010 Instructor: Michael Eckmann.
Geometric Transformations
Introduction Computer Graphics & Its application Types of computer graphics Graphic display : random Scan & Raster Scan display Frame buffer and video.
Graphics Output Primitives
CGMB214: Introduction to Computer Graphics
 A line segment in a scene is defined by the coordinate positions of the line end-points x y (2, 2) (7, 5)
Computer Graphics 2D Transformations. 2 of 74 Contents In today’s lecture we’ll cover the following: –Why transformations –Transformations Translation.
ELLIPSE GENERATING ALGORITHMS 1. DEFINITION Ellipse is an elongated circle. Elliptical curves can be generated by modifying circle-drawing procedures.
Image Synthesis Rabie A. Ramadan, PhD 7. 2 Image Rasterization.
MIDPOINT CIRCLE & ELLIPSE GENERARTING ALGORITHMS
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.
Module 6 Mid-Chapter Test Review. Describe the Transformation from the Given Pre-Image to the Given Image 1. Pre-Image: Shape 1 Image: Shape 4 1. Answer:
CS 325 Introduction to Computer Graphics 02 / 03 / 2010 Instructor: Michael Eckmann.
1 CSCE 441 Lecture 2: Scan Conversion of Lines Jinxiang Chai.
GEOMETRY AND LINE GENERATION Geometry and Line Generation Chapter 2.
In the name of God Computer Graphics. Today Introduction Sampling Graphic Output Primitives 1.Line 2.Circle 3.Curve 4.polygon.
1 Teaching Innovation - Entrepreneurial - Global The Centre for Technology enabled Teaching & Learning, N Y S S, India DTEL DTEL (Department for Technology.
Bresenham’s Line Algorithm
OUTPUT PRIMITIVES A.Aruna/Faculty of Information technology/SNSCE13/19/2016.
Lecture 2: 19/4/1435 Graphical algorithms Lecturer/ Kawther Abas CS- 375 Graphics and Human Computer Interaction.
Instructor: Dr. Shereen Aly Taie If (P>0)
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.
Computer Graphic 2 D Transformation.
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
Scan Conversion of Line Segments. What is Scan conversion? Final step of rasterization (the process of taking geometric shapes and converting them into.
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.
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
Raster Graphics.
MID-POINT CIRCLE ALGORITHM
Lecture 9 Line Drawing Algorithms (Bresenham’s Line Algorithm)
Lecture 05: Mid-point Ellipse algorithm Dr. Manal Helal – Fall 2014
Section 1.1 The Distance and Midpoint Formulas; Graphing Utilities; Introduction to Graphing Equations.
Chapter Three Part I Output Primitives CS 380.
The Unit Square Saturday, 22 September 2018.
Scan Conversion of Circles
Rasterizing Lines 1 Lecture 32 Mon, Nov 12, 2007.
Chapter 3 Graphics Output Primitives
Presentation transcript:

Write Bresenham’s algorithm for generation of line also indicate which raster locations would be chosen by Bresenham’s algorithm when scan converting a line from screen co-ordinate (1,0) to (10,3). Reflect the diamond shape polygon whose vertices are A(-2,0), B(0,-1), C(2,0), D(0,1) about an arbitrary line L which is represented by equations y=0.5x+1. Discuss Breshnham’s Circle algorithm with suitable example. Explain DDA algorithm for generation of line. What is a geometric transformation? Define and explain the following With respect to 2-D transformations (any three) : (i) Translation (ii) rotation (iii) scaling (iv) reflection

A rectangle is formed by the four point ABCD, whose co- ordinates are: A = (25,25), B = (25,125), C = (75, 125) and D = (75, 25) Calculate the new co-ordinates: (i) If it is changed by scaling factors Sx=0.4 and Sy=0.6 (ii) When after scaling Centre is remained at same position and scaling factor is 1.5 Using transformation matrix determine the new coordinates of triangle A(0,0), B(3,2) and C(2,3) after it is rotated 45 degree clockwise about origin A triangle ABC with vertices A(0,0), B(4,0) and C(2,3). Perform the following operations for it. (i) Translation through 4 and 2 units along X and Y directions respectively. (ii) Rotation through 900 In counterclockwise direction about the new position of point C. A rectangle formed by four points PQRS whose coordinates are P(50,50), Q(100,50), R(100,80), S(50,80).Find the new coordinates of the rectangle in reduced size using scaling factors SX = 0.5 and SY = 0.6 Explain 3-D geometric transformations (any three) in detail.

Introduction Computer Graphics Computer graphics deals with the generation of a two-dimensional of a three dimensional model of an object using a graphics software. The process begins with the data input and ends with the generation of a model. We can generate a model either with the help of a programming or by using the software.

Application of computer graphics: The computer graphics is commonly used in areas such as: science, engineering medicine, business, entertainment, advertising, education, art, industry etc. The computer graphics has contributed significantly for developments in the fields involving simulation and animation.

Line generating algorithms: Bresenham’s line algorithm An accurate and efficient raster line-generating algorithm developed by Bresenham. Vertical axis- scan line position Horizontal axis- pixel column At x intervals in these examples, we need to decide which of two possible pixel positions is closer to the line path at each sample step. Starting from the left endpoint shown in fig. we need to determine at the next sample position whether to plot the pixel at position (11,11) or the one at (11,12). 14   13 12 11 10

To illustrate Bresenham’s approach, we first consider the scan-conversion process for lines with positive slope less than 1. Pixel positions along a line path are then determined by sampling at unit x intervals. Starting from the left endpoint (x0,y0) of a given line, we step to each successive column and plot the pixel whose y value is closest to the line path. Fig demonstrates the kth step in this process. Assuming we have determined that the pixel at (xk,yk) is to be displayed, we next need to decide which pixel to plot in column xk+1. Our choices are the pixels at positions (xk +1,yk) and (xk+1,yk+1).

At sampling position xk +1, we label vertical pixel separations from the mathematical line path as d1 and d2. The y coordinate on the mathematical line at pixel column position xk +1 is calculated as y = m(xk +1) + b Then d1 = y - yk = m(xk +1) + b – yk Yk+4   Yk+3 Yk+2 Yk+1 Yk Xk Xk+1 Xk+2 Xk+3

and d2 = (yk +1) – y = yk +1 - m(xk +1) + b The difference between these two separations is d1 - d2 = m(xk +1) + b – yk - yk +1 - m(xk +1) + b A decision parameter pk for the kth step in the line algorithm can be obtained as per the following. We accomplish this by substituting m = ∆y/∆x, where ∆y and ∆x are the vertical and horizontal separations of the endpoint positions, and defining: pk = ∆x(d1 - d2) = 2 ∆y. xk - 2 ∆x. yk + c The sign of pk is same as the sign of d1 - d2, since ∆x>0 for our example. Parameter c is constant and has the value 2∆y+∆x(2b- 1), which is independent of pixel. If the pixel at yk is closer to the line path then pixel at yk+1 (that is d1is less than d2) then decision parameter pk is negative. In that case, we plot the lower pixel, otherwise we plot the upper pixel.

Coordinate change along the line occur in unit steps in either the x or y directions. Therefore we can obtain the values of successive decision parameters using incremental integer calculations. At step k+1, the decision parameter is evaluated following equation pk+1 = 2 ∆y. xk+1 - 2 ∆x. yk+1 + c Subtracting this equation from preceding equation, we have pk+1 - pk = 2 ∆y.( xk+1 – xk) - 2 ∆x.(yk+1 – yk) But xk+1 = xk +1 pk+1 = pk + 2 ∆y- 2 ∆x.(yk+1 – yk) Where the term yk+1 – yk is either 0 or 1, depending on the sign of parameter pk.

Midpoint Circle Algorithm Input radius r and circle center (xc , yc) and obtain the first point on the circumference of a circle centered on the origin as (x0 , y0) = (0,r) Calculate the initial value of the decision parameter as p0 = 5/4 – r At each xk position, starting at k = 0 perform the following test. If pk˂0, the next point along the circle centered on (0,0) is (xk+1 , yk) and pk+1 = pk + 2xk+1 + 1 Otherwise, the next point along the circle is (xk+1, yk-1) and pk+1 = pk + 2xk+1 + 1- 2yk+1 where 2xk+1 = 2xk + 2 and 2yk+1 = 2yk - 2 Determine symmetry points in the other seven octants Move each calculated pixel position (x,y) onto the circular path centered on (xc , yc) and plot the coordinate values. x = x+xc , y = y+yc Repeat steps 3 through 5 until x≥ y.