about bresenham algorithm
MrLiujiefei opened this issue · comments
MrLiujiefei commented
I went through bresenham's push to process:
plotLine(x0, y0, x1, y1)
dx = x1 - x0
dy = y1 - y0
D = 2*dy - dx
y = y0
for x from x0 to x1
plot(x,y)
if D > 0
y = y + 1
D = D - 2*dx
end if
D = D + 2*dy
But I found that your derivation process is:
this->motorList[i]->B = 2 * this->motorList[i]->A - this->leadMotor->A;
if ((*slave)->B >= 0)
{
(*slave)->doStep();
(*slave)->B -= leadMotor->A;
}
(*slave)->B += (*slave)->A;
the leadMotor's A is dx, the slave Motor's A is dy, the B is D, why not :
if ((*slave)->B >= 0)
{
(*slave)->doStep();
*(slave)->B -= 2 * leadMotor->A;
}
**(slave)->B += 2 * (slave)->A;