Incremental computation
At each step q = [x,y] changes either to [x+1,y]
(step to the right) or to [x+1,y+1] (step to the right and up ); in vector form, the new value of q is
either q +D1 or q+D2, with D1=[1,0] and D2=[1,1]
Fnext = (n,2q+2D + 2d1 -2p1) = (n,2q+ 2d1 -2p1) + 2(n,D)
= F + 2(n,D), where D is D1 or D2
At each step, to get new F we have to increment
old F either by (n,D1) or (n,D2)
(n,D2) = (y2-y1) - (x2-x1)