Raster conversion algorithms for line and circle Introduction - Pixel addressing - Primitives and attributes Line drawing algorithms - DDA - Bresenham.

  • Published on
    19-Dec-2015

  • View
    219

  • Download
    2

Embed Size (px)

Transcript

<ul><li> Slide 1 </li> <li> Raster conversion algorithms for line and circle Introduction - Pixel addressing - Primitives and attributes Line drawing algorithms - DDA - Bresenham Circle generating algorithms - Direct method - Bresenham algorithm </li> <li> Slide 2 </li> <li> Pixel addressing in raster graphics </li> <li> Slide 3 </li> <li> Raster conversion algorithms: requirements visual accuracy spatial accuracy speed </li> <li> Slide 4 </li> <li> Line drawing algorithms </li> <li> Slide 5 </li> <li> Line raster representation </li> <li> Slide 6 </li> <li> DDA ( Digital Differential Algorithm ) m &lt; 1 </li> <li> Slide 7 </li> <li> DDA ( Digital Differential Algorithm ) m &gt; 1 </li> <li> Slide 8 </li> <li> DDA ( Digital Differential Algorithm ) m &gt; 1 </li> <li> Slide 9 </li> <li> Digital Differential Algorithm input line endpoints, (x 0,y 0 ) and (x n, y n ) set pixel at position (x 0,y 0 ) calculate slope m Case |m|1: repeat the following steps until (x n, y n ) is reached: y i+1 = y i + y/ x x i+1 = x i + 1 set pixel at position (x i+1,Round(y i+1 )) Case |m|&gt;1: repeat the following steps until (x n, y n ) is reached: x i+1 = x i + x/ y y i+1 = y i + 1 set pixel at position (Round(x i+1 ), y i+1 ) </li> <li> Slide 10 </li> <li> Bresenham's line algorithm y = mx + b d1 d2 xx+1 y y = m(x+1) + b y = mx + b </li> <li> Slide 11 </li> <li> Bresenham's line algorithm (slope 1) input line endpoints, (x 0,y 0 ) and (x n, y n ) calculate x = x n - x 0 and y = y n - y 0 calculate parameter p 0 = 2 y - x set pixel at position (x 0,y 0 ) repeat the following steps until (x n, y n ) is reached: if p i &lt; 0 set the next pixel at position (x i +1, y i ) calculate new p i+1 = p i + 2 y if p i 0 set the next pixel at position (x i +1, y i + 1 ) calculate new p i+1 = p i + 2( y - x) </li> <li> Slide 12 </li> <li> DDA versus Bresenhams Algorithm DDA works with floating point arithmetic Rounding to integers necessary Bresenhams algorithm uses integer arithmetic Constants need to be computed only once Bresenhams algorithm generally faster than DDA </li> <li> Slide 13 </li> <li> Circle generating algorithms Direct Polar coordinate based Bresenhams </li> <li> Slide 14 </li> <li> Direct circle algorithm Cartesian coordinates Circle equation: ( x - x c ) 2 + ( y - y c ) 2 = r 2 Step along x axis from x c - r to x c + r and calculate y = y c r 2 - ( x - x c ) 2 </li> <li> Slide 15 </li> <li> Polar coordinates Polar coordinate equation x = x c + r cos y = y c + r sin step through values of from 0 to 2 </li> <li> Slide 16 </li> <li> Optimisation and speed-up Symmetry of a circle can be used Calculations of point coordinates only for a first one-eighth of a circle (x,y) (y,x) (x,-y) (y,-x) (-x,y) (-y,x) (-y,-x) (-x,-y) </li> <li> Slide 17 </li> <li> Bresenhams circle algorithm 1. Input radius r 2. Plot a point at (0, r) 3. Calculate the initial value of the decision parameter as p 0 = 5/4 r 1 r </li> <li> Slide 18 </li> <li> 4. At each position x k, starting at k = 0, perform the following test: if p k &lt; 0 plot point at (x k +1, y k ) compute new p k+1 = p k + 2x k+1 + 1 else plot point at (x k + 1, y k 1) compute new p k+1 = p k + 2x k+1 + 1 2y k+1 where x k+1 = x k + 1 and y k+1 = y k - 1 </li> <li> Slide 19 </li> <li> 5. Determine symmetry points in the other seven octants and plot points 6. Repeat steps 4 and 5 until x y </li> </ul>

Recommended

View more >