This is equivalent to the Bresenham line algorithm for generating a diagonal line from a series of pixels, where you have to go "up 15" and "right 10", but want them evenly distributed, and want to do it quickly. Each of your A and B represent the "up" and "right" steps.