Computer Graphics I

Assignment 11

Group III (Yavor Kaloyanov)

Jan Hendrik Dithmar

2031259

Pascal Gwosdek

2505221

Assignment 11  Dithmar (2031259), Gwosdek (2505221)

11.1 Extended Bresenham

Line from (x_{0}, y_{0}) to (x_{1}, y_{1}) with slope in ]0, 1[ (slope at 0 or 1 is trivial). Here is some pseudo-code:

a = y1 − y0 ;
b = x1 − x0 ;
x = x0 ;
y = y0 ;
d = 2a − b ;
while (2 x <= x0 + x1 )

{

s e t p i x e l (x , y ) ;
s e t p i x e l ( x1 − x + x0 , y1 − y + y0 ) ;
i f (d <= 0)
d += 2a ;

else {

d += 2a − 2b ;
y++;

}

x++;

}

0 1 2 3 4 5 6 7 8 9 012

Figure 1: Sample visualisation of the Bresenham algorithm for lines, here shown from (0,0) to (9,2). The line is being constructed in a ’mirrored’ manner.

Assignment 11  Dithmar (2031259), Gwosdek (2505221)

11.2 Bresenham for Parabola

Here is some pseudo-code:

x = 0 ;
y = 2 ;
d = −0.5 / 1 . 2 ;
while ( x != b)

{

s e t p i x e l (x , y ) ;
i f (d <= 0)
d += 1/6 ∗ x + 1/12;

else {

d += 1/6 ∗ x + 1/12 − 1 ;
y++;

}

x++;

}

0 1 2 3 4 5 6 2345

Figure 2: Visualisation of the Bresenham algorithm for the parabula from (0,2) to (6,5).