# Distance

Distance is defined to be the magnitude or size of displacement between two positions. Note that the distance between the two positions is not the same as the distance traveled between them. Distance traveled is the total length of the path traveled between two positions. Although displacement is described in terms of direction, distance is not. Distance has no direction and, thus, no sign. It is important to note that the distance traveled, however, can be greater than the magnitude of the displacement (by magnitude, we mean just the size of the displacement without regard to its direction; that is, just a number with a unit).

## The distance formula

The distance between two points $$A$$ and $$B$$ is equal to the length of the segment $$\overline{AB}$$ calculated as the difference between the coordinates of the points themselves. In case you want to calculate the distance between two points on an oriented line, it must be calculated as the difference between the abscissa of $$B$$ and the abscissa of $$A$$, that is:

$\overline{AB}=x_B-x_A$

Given endpoints $$A=(x_A,y_A)$$ and $$B=(x_B,y_B)$$, the distance between two points is given by:

$d(A,B)=\sqrt{(x_B-x_A)^2+(y_B-y_A)^2}$

Similarly, the distance between two points $$A=(x_A,y_A,z_A)$$ and $$B=(x_B,y_B,z_B)$$ in xyz-space (3D) is given by the following generalization of the distance formula:

$d(A,B)=\sqrt{(x_B-x_A)^2+(y_B-y_A)^2+(z_B-z_A)^2}$