If line joining p and q is parallel to y axis , then count is difference of x values
if ( p . y == q . y ) return Math . abs ( p . x - q . x ) - 1 ; return gcd ( Math . abs ( p . x - q . x ) , Math . abs ( p . y - q . y ) ) - 1 ; }