Assume the two line-defining points are distinct. Put and . The triangle formed by the three points has area . The same area is half the base length times the perpendicular height from the third point to the line. Hence the distance from a point to a line in three dimensions is
This remains valid when the nearest point lies outside the segment, since the base line is infinite. If all three points are collinear, the numerator and distance are both zero.