AC is parallel to the x-axis, it is part of the line y = y1, so the y-coordinate of C is y1.
BC is parallel to the y-axis, it is part of the line x = x2, so the x-coordinate of C is x2.
AC is perpendicular to BC so ACB is a right angle.
Since ABC is a right-angled triangle,
AB2 = AC2 + BC2 (Pythagoras)
Now, AC is a horizontal line so
AC = x2 - x1
BC is a vertical line so BC = y2 - y1
AB2 = (x2 - x1)2 + (y2 - y1)2
Hence the length of AB is
What this means is that