7. Distance of a point from a line


If the straight line is parallel to a Cartesian axis, the problem is trivial. It is sufficient to calculate the absolute value of the difference between the ordinate of the point and the common ordinate of the points of the line, if the line is parallel to the x-axis, or between the abscissa of the point and the common abscissa of the points on the line, if the line is parallel to the y-axis.

If instead the straight line is not parallel to any of the axes and does not pass through the origin, its equation has the following form

Eqn001.gif

with a≠0, b≠0, c≠0 and intersects the axes respectively at the points

Eqn002.gif

fig001.gif

The distance AH of a point A(xA;yA) from the straight line coincides with the height of the triangle PAQ with respect to the base PQ, and therefore can be obtained by dividing twice the area of that triangle by the measure of the base PQ.

If we apply the expression (2.3) to calculate the area of a triangle from the coordinates of its ends and the Pythagorean theorem to the triangle OPQ to calculate the length of PQ, we get

Eqn003.gif

and simplifying

Eqn004.gif

If instead the line passes through the origin, its equation has the form

Eqn005.gif

Let S be the point of the line with abscissa 1. We have

fig002.gif

Eqn006.gif

In this case the distance AH of the point A from the line is obtained by dividing twice the area of the triangle by the distance of S from the origin:

Eqn007.gif

As we can see, the result is the same as (7.3) with c=0.

We can apply the (7.3) to obtain the equations of the bisectors of the angles formed by two intersecting lines.

In fact the bisector of an angle is the locus of points equidistant from the sides. Then, if x e y are the coordinates of a point of the Cartesian plane and the intersecting lines have equations

Eqn008.gif

we have

Eqn009.gif

The equation (7.6) represents two bisectors because two intesercting lines form two pairs of opposite angles and each pair of opposite angles has the same bisector. The two bisectors are perpendicular, so the product of their slopes is -1.

The following JavaScript calculates the distance between a point and a line and draws both the elements.
You can enter the numeric data as integers, fractions, decimals or symbols like E and P or also as values of simple functions (for example Sqrt[2], Sin[1], etc.).
The application works only if your browser allows pop-ups.