Robin2:

polyglot:
the best way is to learn about Bresenham's Algorithm and work from there. It's a neat way of drawing a straight line when you have discrete output steps, eg pixels or CNC steps.

Just out of curiosity on my part, is it different from the mechanism I suggested in Reply #7?

...R

If you're willing to have a loop that is as long as the lowest common multiple of the line dx and dy values, it's functionally the same. But consider the case where you want to draw a line that is of interesting (ratio of two relatively prime numbers) and length 100,000: the loop length in your algorithm will be 10 billion and the tool will move extremely slowly.

Bresenham explicitly tracks the remainder in a variable instead of iterating the remainder so it is far more efficient in the general case. Classic Bresenham (for graphics) tracks the slope of your line in X/Y; for CNC you run 3 (or more) parallel Bresenham instances that track the slope of X/t, Y/t, Z/t.

GRBL takes G-code, ie instructions like "move to X,Y,Z at speed S", plus curves and all that good stuff. So yes, drawing lines is about the simplest thing it does. It will even handle acceleration & deceleration in a line!