30/9/2008Lecture 21 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester 2008-2009 ITGD3107 University of Palestine.

Slides:



Advertisements
Similar presentations
Line Drawing Algorithms
Advertisements

Graphics Primitives: line
5.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 5 – Drawing A Line.
COMP 175 | COMPUTER GRAPHICS Remco Chang1/6103b – Shapes Lecture 03b: Shapes COMP 175: Computer Graphics February 3, 2015.
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1 Emmanuel Agu.
Section 3-1 to 3-2, 3-5 Drawing Lines Some of the material in these slides may have been adapted from university of Virginia, MIT, and Åbo Akademi University.
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.
Scan Conversion A. Samal. Scan Conversion Last step in the graphics pipeline Efficiency is a central issue Common primitives – Lines – Polygons – Circles.
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.
Lecture 5 Rendering lines 1.Steps of line rendering 2.Scan-conversion for line segments 3.A1 tutorial CP411 Computer Graphics Fall 2007 Wilfrid Laurier.
Scan conversion of Line , circle & ellipse
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 Lecture 3 Line & Circle Drawing.
Lecture 2 Line & Circle Drawing
OUTPUT PRIMITIVES Screen vs. World coordinate systems ● Objects positions are specified in a Cartesian coordinate system called World Coordinate.
Raster conversion algorithms for line and circle
Output Primitives Computer Graphics.
Graphics Output Primitives Pixel Addressing and Fill Area Dr. M. Al-Mulhem Feb. 1, 2008.
CAP4730: Computational Structures in Computer Graphics Chapter 3 Hearn & Baker Portions obtained from Leonard McMillan’s COMP136 Notes:
CS 450: COMPUTER GRAPHICS DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE.
1 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD3107 University of Palestine.
March Shape Drawing Algorithms Shmuel Wimer Bar Ilan Univ., Engineering Faculty.
Dr. Scott Schaefer Scan Conversion of Lines. 2/78 Displays – Cathode Ray Tube.
1/1/20001 Topic >>>> Scan Conversion CSE Computer Graphics.
College of Computer and Information Science, Northeastern UniversitySeptember 12, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture.
IT- 601: Computer Graphics Lecture-03 Scan Conversion
Dr. S.M. Malaek Assistant: M. Younesi
Jehee Lee Seoul National University
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
1Computer Graphics Implementation III Lecture 17 John Shearer Culture Lab – space 2
Graphics Graphics & Graphical Programming Lecture 14 - Lines & Circles.
Graphics Output Primitives
CGMB214: Introduction to Computer Graphics
Image Synthesis Rabie A. Ramadan, PhD 7. 2 Image Rasterization.
Computer Graphics Drawing Line. Lines and Polylines Convex: For every pair of points in the polygon, the line between them is fully contained in the polygon.
Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2.
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.
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.
MIT EECS 6.837, Durand and Cutler The Graphics Pipeline: Line Clipping & Line Rasterization.
Lecture 13: Raster Graphics and Scan Conversion
1 Module U08181: Computer Graphics graphics primitives part 1: scan conversion and filling.
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.
Rasterization Overview Raster Display Device. Scan Conversion / Rasterization: converting vector graphics into raster graphics (determining pixels in.
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 : output primitives.. 2 of 32 T1 – pp. 103–123, 137–145, 147–150, 164–171 Points and LinesPoints Line Drawing AlgorithmsLine Mid–Point.
OUTPUT PRIMITIVES CEng 477 Computer Graphics METU, 2004.
Primitive graphic objects
Scan Conversion or Rasterization
Computer Graphics Drawing Line.
CSCE 441 Lecture 2: Scan Conversion of Lines
(c) 2002 University of Wisconsin, CS559
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
Scan Conversion or Rasterization
Prof. Harriet Fell Spring 2007 Lecture 5 – January 17, 2006
Chapter Three Part I Output Primitives CS 380.
CSCE 441 Lecture 2: Scan Conversion of Lines
Introduction to Computer Graphics
Rasterization and Antialiasing
Rasterization and Antialiasing
Scan Conversion (From geometry to pixels)
Chapter 3 Graphics Output Primitives
Presentation transcript:

30/9/2008Lecture 21 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD3107 University of Palestine

30/9/2008Lecture 22 Chapter 3 Output Primitives line, circle, Ellipse algorithms and others ITGD3107 Computer Graphics

30/9/2008Lecture 23 Output Primitives What Kind of Math do We Need? Drawing Lines, Circles, Ellipses Filled Polygons and Characters Ideal Line, simple line Vector Generation DDA Algorithm Bresenham algorithm Circle Drawing algorithms Ellipse Drawing algorithms Representing Characters Drawing Filled Polygons

30/9/2008Lecture 24 What Kind of Math do We Need? Cartesian Coordinates Typically modeling space is floating point, screen space is integer screen coordinates are measured top to bottom, based on raster scan (0,0) x, y Cartesian grid Integer Grid

30/9/2008Lecture 25 Example 3D Primitives Polyhedron Sphere Polyline Patch

30/9/2008Lecture 26 Drawing Lines For horizontal, vertical and diagonal lines all pixels lie on ideal line: special case For lines at arbitrary angle, pick pixels closest to ideal line (Bresenham’s midpoint “scan conversion” algorithm) For thick lines, use multiple pixels in each column or fill a rotated rectangle Sampling continuous line on discrete grid introduces sampling errors: “jaggies”

30/9/2008Lecture 27 Towards the Ideal Line We can only do a discrete approximation Illuminate pixels as close to the true path as possible, consider bi-level display only –Pixels are either lit or not lit

30/9/2008Lecture 28 What is an ideal line Must appear straight and continuous –Only possible axis-aligned and 45 o lines Must interpolate both defining end points Must have uniform density and intensity –Consistent within a line and over all lines Must be efficient, drawn quickly –Lots of them are required!!!

30/9/2008Lecture 29 Simple Line Based on slope-intercept algorithm from algebra: y = mx + b Simple approach: increment x, solve for y Floating point arithmetic required

30/9/2008Lecture 210 Does it Work? It seems to work okay for lines with a slope of 1 or less, but doesn’t work well for lines with slope greater than 1 – lines become more discontinuous in appearance and we must add more than 1 pixel per column to make it work. Solution? - use symmetry.

30/9/2008Lecture 211 Modification OR, increment along x-axis if dy<dx else increment along y-axis

30/9/2008Lecture 212 Vector Generation There are two vector generation algorithm: DDA = Digital Differential Analyser –finite differences Bresenham’s Algorithm

30/9/2008Lecture 213 DDA algorithm DDA = Digital Differential Analyser –finite differences Treat line as parametric equation in t : Start point End point

30/9/2008Lecture 214 DDA Algorithm Start at t = 0 At each step, increment t by dt Choose appropriate value for dt Ensure no pixels are missed: –Implies: and Set dt to maximum of dx and dy

30/9/2008Lecture 215 DDA algorithm line(int x1, int y1, int x2, int y2) { float x,y; int dx = x2-x1, dy = y2-y1; int n = max(abs(dx),abs(dy)); float dt = n, dxdt = dx/dt, dydt = dy/dt; x = x1; y = y1; while( n-- ) { point(round(x),round(y)); x += dxdt; y += dydt; } n - range of t.

30/9/2008Lecture 216 DDA algorithm Still need a lot of floating point arithmetic. –2 ‘round’s and 2 adds per pixel. Is there a simpler way ? Can we use only integer arithmetic ? –Easier to implement in hardware.

30/9/2008Lecture 217 Bresenham (mid-point) algorithm Choose between 2 pixels at each step based upon the sign of a decision variable. Update the decision variable based upon which pixel is chosen. Start point is simply first endpoint (x 1, y 1 ). Need to calculate the initial value for d

30/9/2008Lecture 218 Bresenham algorithm m<1 void MidpointLine1(int x1,y1,x2,y2) { int dx=x2-x1; int dy=y2-y1; int d=2*dy-dx; int increE=2*dy; int incrNE=2*(dy-dx); x=x1; y=y1; WritePixel(x,y); while (x < x2) { if (d<= 0) { d+=incrE; x++ } else { d+=incrNE; x++; y++; } WritePixel(x,y); }

30/9/2008Lecture 219 Bresenham algorithm m>=1 void MidpointLine2(int x1,y1,x2,y2) { int dx=x2-x1; int dy=y2-y1; int d=2*dx-dy; int increE=2*dx; int incrNE=2*(dx-dy); x=x1; y=y1; WritePixel(x,y); while (y < y2) { if (d<= 0) { d+=incrE; y++; } else { d+=incrNE; x++; y++; } WritePixel(x,y); }

30/9/2008Lecture 220 Drawing Circles and Ellipses circle outline filled ellipse

30/9/2008Lecture 221 Circle drawing. Can also use Bresenham to draw circles. Use 8-fold symmetry Choices for Next pixel M E SE Previous Pixel Choices for Current pixel

30/9/2008Lecture 222 Circle drawing. First method is: Where x value steps from to

30/9/2008Lecture 223 Circle drawing. Second method is:

30/9/2008Lecture 224 Circle drawing.

30/9/2008Lecture 225 Example: Midpoint Circle algorithm:

30/9/2008Lecture 226 Ellipse Drawing

30/9/2008Lecture 227 Midpoint Ellipse Algorithm

30/9/2008Lecture 228 Example: Midpoint Ellipse Algorithm

30/9/2008Lecture 229 Example: Midpoint Ellipse Algorithm

30/9/2008Lecture 230 Drawing Characters For characters defined by small bitmap –selectively write pixels of refresh buffer corresponding to “true” bits of character bitmap –Outline fonts: defined in terms of (mathematical) drawing primitives (lines, arcs, etc).

30/9/2008Lecture 231 Representing Characters

30/9/2008Lecture 232 Drawing Filled Polygons 1.Find intersection of scan line with polygon edges 2.Sort intersections by increasing x 3.Fill the polygon between pairs of intersections (spans)