05-2Dandassignment1

05-2Dandassignment1 - More on 2D Images More on 2D Images...

Info iconThis preview shows pages 1–14. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: More on 2D Images More on 2D Images and and Intro to 3D Rendering Intro to 3D Rendering Lecture 5 CPSC 478/578 Spring 2005 TODAY Rendering a 2D Line Intro to Assignment #1 Image formats Paint programs OpenGL FLTK 9 3D Rendering Overview Course Syllabus I. Image processing II. Rendering III. Modeling IV. Animation Image Processing Modeling Animation Rendering Course Syllabus I. Image processing II. Rendering III. Modeling IV. Animation Image Processing Modeling Animation Rendering Rendering Generate an image from geometric primitives Rendering Geometric Primitives Raster Image A Simple Primitive: Rendering a 2D Line Which pixels should be turned to approximate this line ? A Simple Primitive: Rendering a 2D Line Which pixels should be turned black to approximate this line ? Dont want gaps, Want it to look smooth Bresenhams Algoritm Bresenhams algorithm originally developed for pen plotters with stepper motors more background demos: http://www.cs.unc.edu/~mcmillan/comp136/Lecture6/Lines.html Problem Statement Given two points P and Q in the plane, determine which pixels on a raster screen should be on in order to make a picture of a unit-width line segment starting at P and ending at Q (Explanation reformatted lecture slides by Andy van Dam) Procedure Step 1: Round coordinates of P and Q to integers to find pixels at end points. P P Q Q Special cases: Horizontal Line: Draw pixel P and increment the x coordinate value by one to get the next pixel. Vertical Line: Draw pixel P and increment the y coordinate value by one to get the next pixel. Diagonal Line: Draw pixel P and increment both the x and the y coordinate by one to get the next pixel. What should we do in the general case? Increment the x coordinate by 1 and choose the point closest to the line. But how do we measure closest? Finding the next pixel: P P P Why can we use the vertical distance as a measure of which point is closer? because the vertical distance is proportional to the actual distance how do we show this? with congruent triangles By similar triangles we can see that the true distances to the line (in blue) are directly proportional to the vertical distances to the line (in black) for each point Therefore, the point with the smaller vertical distance to the line is the closest to the line Vertical Distance ( x 1 , y 1 ) ( x 2 , y 2 ) The Basic Algorithm Find the equation of the line that connects the two points P and Q in the form y= mx+B, where m = slope, B = y intercept Starting with the leftmost point P, increment x i by 1 to calculate y i = mx i + B Choose the pixel at (x i , Round(y i )) where Round (y i ) = Floor (0.5 + y i ) The Incremental Algorithm: Each iteration requires a floating-point multiplication therefore, modify the algorithm....
View Full Document

Page1 / 54

05-2Dandassignment1 - More on 2D Images More on 2D Images...

This preview shows document pages 1 - 14. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online