标签:
DDA算法#include <stdlib.h>
#include <math.h>
inline int round(const float a) {return int (a + 0.5);}
void lineDDA(int x0,int y0,int xEnd,int yEnd){
int dx = xEnd - x0, dy = yEnd - y0,steps, k ;
float xIncrement, yIncrement,x = x0,y = y0;
if(fabs(dx)>fabs(dr))
steps = fabs(dx);
else
steps = fabs(dy);
xIncrement = float (dx) / float (steps);
yIncrement = float (dy) / float (steps);
setPixel (round(x),round(y));
for(k = 0;k<steps;k++){
x += xIncrement;
y += yIncrement;
setPixel(round(x),round(y));
}
}标签:
原文地址:http://blog.csdn.net/heyuchang666/article/details/51162259