我用武技术写了一条线图算法。 它发挥作用,但存在问题。 见下文。
我不禁要问的是,是否有任何人解决了划定反恐怖线的问题? 简言之,单角搜索结果没有令人满意的算法。 脱离图形图书馆,但并非完全可靠的算法。
如果有人想为以下职能制定样本代码,我就知道。 我希望用更强有力的职能来取代这一职能,但我尚未发现。 我确信,我的算法可以改进,但可以改进。
struct xya { int x; int y; uint8_t a; xya(int x=0, int y=0, uint8_t a=0) : x(x), y(y), a(a) {} }; inline void wuline(xya*& out, int x0, int y0, int x1, int y1) { short DeltaX, DeltaY, XDir; static const int intensity = 8; if (y0 > y1) { short Temp = y0; y0 = y1; y1 = Temp; Temp = x0; x0 = x1; x1 = Temp; } *out++ = xya(x0,y0,255); if ((DeltaX = x1 - x0) >= 0) { XDir = 1; } else { XDir = -1; DeltaX = -DeltaX; } if ((DeltaY = y1 - y0) == 0) { while (DeltaX-- != 0) { x0 += XDir; *out++ = xya(x0,y0,255); } return; } if (DeltaX == 0) { do { y0++; *out++ = xya(x0,y0,255); } while (--DeltaY != 0); return; } if (DeltaX == DeltaY) { do { x0 += XDir; y0++; *out++ = xya(x0,y0,255); } while (--DeltaY != 0); return; } if (DeltaY > DeltaX) { unsigned short ErrorAcc = 0; unsigned short ErrorAdj = ((unsigned long) DeltaX > intensity; *out++ = xya(x0,y0,Weighting ^ 255); *out++ = xya(x0+XDir,y0,Weighting); } *out++ = xya(x1,y1,255); } else { unsigned short ErrorAcc = 0; unsigned short ErrorAdj = ((unsigned long) DeltaY > intensity; *out++ = xya(x0,y0,Weighting ^ 255); *out++ = xya(x0,y0+1,Weighting); } *out++ = xya(x1,y1,255); } }