The distance formula
In 2D: d = sqrt((x2-x1) squared + (y2-y1) squared). In 3D, add the z-component: d = sqrt((x2-x1) squared + (y2-y1) squared + (z2-z1) squared).
The midpoint is the average of the coordinates: ((x1+x2)/2, (y1+y2)/2) in 2D, with the z-average added for 3D.
d = sqrt((x2-x1)^2 + (y2-y1)^2)
Euclidean distance in 2D.