Tuesday, April 10, 2007

Pusooy Games Tutorial

Improvement pending algorithm for m = 1 and m = Previous

Improvement Bresenham line algorithm


lineaBresenham void (int xo, yo, x1 , y1) {int dx = x1
-xo;
int dy = y1-yo;
int x = xo;
int y = I;
int do = 2 * dy-dx;
int dE = 2 * dy;
int DNE = 2 * (dy-dx);
int d = do;
int m = (y1-yo) / (x1-xo);
while (x! = x1) {
if (d <= 0){ //Direccion E
point ( x, y);
x = x + m;
d = d + dE;}

else {/ / Address
NE point (x, y);
x = x + m;
y = y +1;
d = d + DNE;

}}}


This code uses To sum the slope to calculate Tl x d, and so able to handle pendientesde m = 1 and m =- 1 or greater in value. Computer Graphics Group 2

0 comments:

Post a Comment