03-25-2018, 07:51 PM
(03-25-2018, 05:13 PM)PaukkuPalikka Wrote: Can you describe the line drawer in more detail? Things like what algorithm does it use, how it is implemented in redstone etc.
Sure
First of all i want to say sorry for my bad enlgish
Okay the line drawer its based on bresenham
Lets see the algorithm:
Fisrt we need to calculate some fixed values (Dy Dx P and A)
Dy= Abs of Y1-Y2
Dx= Abs of X1-X2
P= 2Dy-Dx
A= 2Dy-2Dx
Then we start the loop that is:
If P = neg
P= P + 2Dy
X = X+1
Y = Y
else
P = P + A
X = X+1
Y =Y +1
Thats the algo now the implementation on redstone
The fixed values are done by adders(lots ._.)
The we run a loop of the P in one adder(getting the clockspeed to 13 ticks)
This adder can take all tipes of lines so imma explain how that is done:
1-Go back in Y or X:
when we calc Dy or Dx we can know if they need to increment or decrement loking if they are positive or negative
2- Take high slope:
We detect high slope:
Dy-Dx
if the result is positive we invert inputs(So X gets looped instead of Y) and outputs(to put X and Y in his place again)
Okay this is the end i dont think i can explain it better than this