OUTPUT PRIMITIVES 2010-2011. Screen vs. World coordinate systems ● Objects positions are specified in a Cartesian coordinate system called World Coordinate.

Slides:



Advertisements
Similar presentations
Graphics Primitives Part II: Bresenhams line and circle.
Advertisements

Graphics Primitives: line
Okay, you have learned … OpenGL drawing Viewport and World Window setup main() { glViewport(0,0,300,200); glMatrixMode(GL_PROJECTION); glLoadIndentity();
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1 Emmanuel Agu.
Line and Curve Drawing Algorithms. Line Drawing x0x0 y0y0 x end y end.
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.
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 Algorithms
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.
Larry F. Hodges (modified by Amos Johnson) 1 Design of Line, Circle & Ellipse Algorithms.
30/9/2008Lecture 21 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD3107 University of Palestine.
Advanced Manufacturing Laboratory Department of Industrial Engineering Sharif University of Technology Session # 6.
CMPE 466 COMPUTER GRAPHICS
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
Okay, you have learned … OpenGL drawing Viewport and World Window setup main() { glViewport(0,0,300,200); glMatrixMode(GL_PROJECTION); glLoadIndentity();
2 COEN Computer Graphics I Evening’s Goals n Discuss the fundamentals of lighting in computer graphics n Analyze OpenGL’s lighting model n Show.
In the name of God Computer Graphics Bastanfard.
Raster conversion algorithms for line and circle
Output Primitives Computer Graphics.
University of Missouri at Columbia 2D Scan-line Conversion University of Missouri at Columbia.
Course Website: Computer Graphics 5: Line Drawing Algorithms.
Line Drawing by Algorithm. Line Drawing Algorithms Line drawn as pixels Graphics system –Projects the endpoints to their pixel locations in the frame.
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.
Dr. S.M. Malaek Assistant: M. Younesi
Jehee Lee Seoul National University
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
Informationsteknologi Monday, November 26, 2007Computer Graphics - Class 121 Today’s class Drawing lines Bresenham’s algorithm Compositing Polygon filling.
Objectives Differentiate between raster scan display and random scan display.
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)
Image Synthesis Rabie A. Ramadan, PhD 7. 2 Image Rasterization.
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.
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.
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Computer Graphics Inf4/MSc Computer Graphics Lecture 4 Line & Circle Drawing.
10/10/2006TCSS458A Isabelle Bichindaritz1 Line and Circle Drawing Algorithms.
Rasterization CENG 477 Introduction to Computer Graphics Slides from Steve Marschner, CS4620, 2008 Cornell University.
Scan Conversion of Line Segments. What is Scan conversion? Final step of rasterization (the process of taking geometric shapes and converting them into.
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.
Line Drawing Algorithms
CSCE 441 Lecture 2: Scan Conversion of Lines
CENG 477 Introduction to Computer Graphics
Lecture 9 Line Drawing Algorithms (Bresenham’s Line Algorithm)
CS 4731: Computer Graphics Lecture 20: Raster Graphics Part 1
Lecture 8 Shear and Line Drawing Algorithms
Chapter Three Part I Output Primitives CS 380.
Computer Graphics 5: Line Drawing Algorithms
Computer Graphics 5: Line Drawing Algorithms
CSCE 441 Lecture 2: Scan Conversion of Lines
2D Scan-line Conversion
Introduction to Computer Graphics
Rasterization and Antialiasing
Computer Graphics 5: Line Drawing Algorithms
Rasterization and Antialiasing
Chapter 3 Graphics Output Primitives
Presentation transcript:

OUTPUT PRIMITIVES

Screen vs. World coordinate systems ● Objects positions are specified in a Cartesian coordinate system called World Coordinate System which can be three dimensional and real-valued. ● Locations on a video monitor are referenced in integer screen coordinates. Therefore object definitions has to be scan converted to discrete screen coordinate locations to be viewed on a video monitor.

Specification of a 2D WCS in OpenGL ● glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluOrtho2D (xmin, xmax, ymin, ymax); ● Objects that are specified within these coordinate limits will be displayed within the OpenGL window.

Output Primitives ● Graphic SW and HW provide subroutines to describe a scene in terms of basic geometric structures called output primitives. ● Output primitives are combined to form complex structures ● Simplest primitives – Point (pixel) – Line segment

Scan Conversion ● Converting output primitives into frame buffer updates. Choose which pixels contain which intensity value. ● Constraints – Straight lines should appear as a straight line – primitives should start and end accurately – Primitives should have a consistent brightness along their length – They should be drawn rapidly

OpenGL Point Functions ● glBegin (GL_POINTS); glVertex2i(50, 100); glVertex2i(75, 150); glVertex2i(100, 200); glEnd();

OpenGL Line Functions ● glBegin (GL_LINES); glVertex2iv(p1); glVertex2iv(p2); glVertex2iv(p3); glVertex2iv(p4); glVertex2iv(p5); glEnd(); p5 p3 p1 p4 p2

OpenGL Line Functions ● glBegin (GL_LINE_STRIP); glVertex2iv(p1); glVertex2iv(p2); glVertex2iv(p3); glVertex2iv(p4); glVertex2iv(p5); glEnd(); p5 p3 p1 p4 p2

OpenGL Line Functions ● glBegin (GL_LINE_LOOP); glVertex2iv(p1); glVertex2iv(p2); glVertex2iv(p3); glVertex2iv(p4); glVertex2iv(p5); glEnd(); p5 p3 p1 p4 p2

Line Drawing Algorithms ● Simple approach: sample a line at discrete positions at one coordinate from start point to end point, calculate the other coordinate value from line equation (slope-intercept line equation). If m>1, increment y and find x If m ≤1, increment x and find y Is this correct?

Digital Differential Analyzer ● Simple approach: too many floating point operations and repeated calculations ● Calculate from for a value

DDA ● Is faster than directly implementing y=mx+b. No floating point multiplications. We have floating point additions only at each step. ● But what about round-off errors? ● Can we get rid of floating point operations completely?

Bresenham's Line Algorithm ● DDA: Still floating point operations x k+1 xkxk ykyk yk+1yk+1 y=mx+b d upper d lower x k+2 x k+3

at step k+1: 0 if p k was negative1 if p k was positive to calculate p 0 at the starting pixel position (x 0,y 0 )

Input: two line end points ( x 0,y 0 ) and ( x end,y end ) draw ( x 0,y 0 ) p k ←2Δy-Δx; x k ←x 0 while x k <x end x k+1 ←x k +1 if p k ≤ 0 choose y k y k+1 ←y k ; p k+1 ←p k +2Δy else choose y k +1 y k+1 ←y k +1; p k+1 ←p k + 2Δy - 2Δx draw ( x k+1,y k+1 ) x k ←x k+1 p k ←p k+1 Bresenham’s Line-Drawing Algorithm

Example from the textbook ● Using Bresenham’s algorithm digitize the line with endpoints (20,10) and (30,18) Solution: ● Δy = (18-10)=8, Δx = (30-20)=10, ● m = Δy / Δx = 0.8, ● p0= 2Δy - Δx = 16 – 10 = 6. ● 2Δy = 16 and (2Δy) - 2Δx = = -4. ● plot the initial point (x0, y0) = (20,10 ● find the following pixel positions along the line:

Example continued

Plotted pixels