You can just use this formula, its what I used in my program:

SquareRoot((X1-X2)²+(Y1-Y2)²)