Lines Revisited: Slope and General Form

Part 13, Chapter 13: Conic Sections in the Coordinate Plane

Learning objectives

  • Write the general form ax + by + c = 0 of a line
  • Find the normal vector to a line
  • Compute the distance from a point to a line
  • Convert between slope-intercept and general form

The slope-intercept form y=mx+by = mx + b is the line you first met. It is fine for sketching, but analytic geometry needs a form that is more symmetric and that does not break down for vertical lines. The general form ax+by+c=0ax + by + c = 0 treats xx and yy on equal footing and instantly reveals the line's normal vector, which is the key to computing distances from points to lines, a tool you will use again and again in the conic sections to follow.

General form

Every straight line in the plane satisfies an equation of the form

ax+by+c=0,qquad(a,b)neq(0,0)ax + by + c = 0, \qquad (a, b) \neq (0, 0)

The pair (a,b)(a, b) controls the direction; the scalar cc slides the line parallel to itself. Vertical lines x=kx = k correspond to b=0b = 0; horizontal lines y=ky = k correspond to a=0a = 0. Slope-intercept cannot express vertical lines, general form can.

The normal vector is the gradient

The vector mathbfn=(a,b)\mathbf{n} = (a, b) points perpendicular to the line. Why? Because if (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) both satisfy ax+by+c=0ax + by + c = 0, subtracting gives a(x1x2)+b(y1y2)=0a(x_1 - x_2) + b(y_1 - y_2) = 0, i.e. mathbfncdot(x1x2,y1y2)=0\mathbf{n} \cdot (x_1 - x_2, y_1 - y_2) = 0. The dot product vanishes, so mathbfn\mathbf{n} is perpendicular to every direction along the line.

The direction vector along the line is (b,a)(-b, a) (rotate the normal by pi/2\pi/2). Either choice of sign works.

Where this shows up
  • Computer Vision: The general-form line ax+by+c=0ax + by + c = 0 is the natural output of the Hough transform; (a,b)(a, b) is the line's normal vector, and cc encodes its signed distance from the origin.
  • Image Processing: Edge-detection filters output gradient vectors that point along the normal (a,b)(a, b) of local edges; aligning these normals across pixels is how line-detection algorithms find roads, walls, and text.
  • Machine Learning: Half-spaces ax+by+cgeq0ax + by + c \geq 0 are the building blocks of linear-programming feasible regions and of support-vector-machine classifiers; both are general-form lines used as decision boundaries.

(Drag the two points to redraw the line. The widget displays both the general form and the slope-intercept form, so you can see them as two views of the same object.)

Distance from a point to a line

The most-used formula in this chapter is

d=dfracax0+by0+csqrta2+b2d = \dfrac{|a x_0 + b y_0 + c|}{\sqrt{a^2 + b^2}}

where (x0,y0)(x_0, y_0) is the external point and ax+by+c=0ax + by + c = 0 is the line. The numerator is the signed value of the line equation at the point; the denominator is the length of the normal vector. Dividing turns "how much does this point miss the equation by" into a true Euclidean distance.

Converting between forms

From slope-intercept: y=mx+ky = mx + k becomes mxy+k=0mx - y + k = 0, so (a,b,c)=(m,1,k)(a, b, c) = (m, -1, k).

From general form: if bneq0b \neq 0, the slope is m=a/bm = -a/b and the yy-intercept is c/b-c/b. Two lines are parallel when a1b2=a2b1a_1 b_2 = a_2 b_1; they are perpendicular when a1a2+b1b2=0a_1 a_2 + b_1 b_2 = 0 (dot product of normals is zero).

Try it

  • Find the distance from (3,1)(3, -1) to 2x+3y6=02x + 3y - 6 = 0. (Plug into the formula.)
  • Write y=tfrac34x+2y = -\tfrac{3}{4}x + 2 in general form with integer coefficients. (Multiply through by 44.)
  • Find the angle between the two lines xy=1x - y = 1 and x+y=3x + y = 3. (Use the normals: their dot product divided by the product of lengths gives costheta\cos\theta.)

Pause: is y=mx+by = mx + b really general, or is it missing some lines? It is missing all vertical lines, because they have undefined slope. The general form fixes this gap.

A trap to watch for

The distance formula needs the line in general form. If you have y=mx+by = mx + b and you plug (x0,y0)(x_0, y_0) into ymxby - mx - b, you do not get the distance, you get the vertical gap from the point to the line. To get the perpendicular distance, you must first rewrite as mxy+b=0mx - y + b = 0, then divide by sqrtm2+1\sqrt{m^2 + 1}. Forgetting the denominator overestimates the distance by a factor of sqrtm2+1\sqrt{m^2 + 1}, which can be huge for steep lines.

What you now know

You can write any line in general form ax+by+c=0ax + by + c = 0 (including verticals), identify the normal vector, compute the perpendicular distance from a point, and translate between slope-intercept and general form. The next section turns these coordinate-method tools loose on curved figures, starting with the parabola.

Quick check

Mark section complete →

References

  • Lang, S. (1971). Basic Mathematics. Springer. Chapter 12, §1, the general-form approach to the line in analytic geometry.
  • Apostol, T. M. (1969). Calculus, Volume 2. Wiley. Chapter 1: lines and planes in vector form, including the point-to-line distance derivation.
  • Hartshorne, R. (2000). Geometry: Euclid and Beyond. Springer. Chapter 3: analytic and synthetic treatments of lines side by side.

This page is prerendered for SEO and accessibility. The interactive widgets above hydrate on JavaScript load.