Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 CS5500 Computer Graphics May 3, 2007.

Similar presentations


Presentation on theme: "CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 CS5500 Computer Graphics May 3, 2007."— Presentation transcript:

1 CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 CS5500 Computer Graphics May 3, 2007

2 CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 Today’s Topic Bresenham’s line drawing algorithm. Reference: Edward Angel’s book: –4 th Ed. Sections 7.8 and 7.9 –3 rd Ed. Sections 8.9 and 8.10.

3 CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 Scan Conversion Also called rasterization. The 3D to 2D Projection gives us 2D vertices (points). We need to fill in the interior.

4 CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 Line Drawing Assuming: –Clipped (to fall within the window) –2D screen coordinates –Each pixel covers a square region where is its center? Rounding (X, Y) implies center at (0.0, 0.0). Truncating implies center at (0.5, 0.5).

5 CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 DDA Algorithm DDA stands for digital differential analyzer. The differential equation for a line is: m = dy / dx

6 CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 Stepping in X direction

7 CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007

8 CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 Bresenham’s Algorithm Improve upon DDA algorithm to use integer arithmetic only. Applicable to circle drawing too. We discuss only the line drawing here.

9 CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 Decision Variables Variables a and b record the distances to the pixel centers of (i+1, j) and (i+1, j+1) If a > b, then y=j If a < b, then y= j+1

10 CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 Integer Only If (x1, y1) and (x2, y2) are integer points, then  x * a and  x * b may be stored as integers as well. –Because a and b increase or decrease by m =  y /  x

11 CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 Using the Symmetry The above works when  x  0,  y  0, and  x   y. If  x <  y, then step in Y direction instead. It is easy to extend it to handle  x < 0 or  y < 0.


Download ppt "CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 CS5500 Computer Graphics May 3, 2007."

Similar presentations


Ads by Google