



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




David Luebke 3/8/
David Luebke 3/8/
n Like those we’re about to discuss… n Such algorithms embed well in hardware
David Luebke 3/8/
David Luebke 3/8/
David Luebke 3/8/
David Luebke 3/8/
David Luebke 3/8/
David Luebke 3/8/
David Luebke 3/8/
David Luebke 3/8/
David Luebke 3/8/
David Luebke 3/8/
David Luebke 3/8/
David Luebke 3/8/
David Luebke 3/8/
l Let C = x 0 y 1 - x 1 y 0 for convenience
=−
1
1
1 1
C B
A
x y
x y
−
−
−
− =
1 0
0 1 1 0 x x
y y
xy xy
C
B
A
David Luebke 3/8/
l Calculating C = x 0 y 1 - x 1 y 0 involves some
David Luebke 3/8/
David Luebke 3/8/
David Luebke 3/8/
David Luebke 3/8/
findBoundingBox(&xmin, &xmax, &ymin, &ymax); setupEdges (&a0,&b0,&c0,&a1,&b1,&c1,&a2,&b2,&c2);
/ Optimize this: / for (int y = yMin; y <= yMax; y++) { for (int x = xMin; x <= xMax; x++) { float e0 = a0x + b0y + c0; float e1 = a1x + b1y + c1; float e2 = a2x + b2y + c2; if (e0 > 0 && e1 > 0 && e2 > 0) setPixel(x,y); } }**
David Luebke 3/8/
int xflag = 0; for (int x = xMin; x <= xMax; x++) { if (e0|e1|e2 > 0) { setPixel(x,y); xflag++; } else if (xflag != 0) break; e0 += a0; e1 += a1; e2 += a2; }
David Luebke 3/8/
David Luebke 3/8/