摘要:
不失一般性,讨论Bresenham算法绘制(0,0)到(dx,dy)的直线,其算法为:acc = acc0;y = 0;for (x = 0; x <= dx; x++){ visit(x, y); acc += Dy; if (acc >= Dx) { acc -= Dx; y++; }} 其中dy*Dx = dx*Dy。用数学表达式描述为:y = ceil( (acc0+x*Dy) / Dx )而反向扫描算法为:acc = acc1;y = dy;for (x = dx; x >= 0; x--){ visit(x, y); acc += Dy; if (acc > 阅读全文