A(x1,y1) B(x2,y2)
k=(y1-y2)/(x1-x2)
k^2=(y1-y2)^2/(x1-x2)^2
(y1-y2)^2=k^2(x1-x2)^2
(x1-x2)^2=(y1-y2)^2/k^2
|AB|=√[(x1-x2)^2+(y1-y2)^2]
=√[(x1-x2)^2+k^2(x1-x2)^2]
=|x1-x2|√(1+k^2)
|AB|=√[(x1-x2)^2+(y1-y2)^2]
=√[(y1-y2)^2/k^2+(y1-y2)^2]
=|y1-y2|√(1/k^2+1)