Direction cosines using two points

Most textbook lines are not handed to you as a neat angle with the axes — they are handed to you as two points, say P(2,3,−1)P(2,3,-1) and Q(5,−1,11)Q(5,-1,11), and you are expected to find the line's direction on your own. This is the single most common way direction cosines actually appear in Class 12 problems: subtract coordinates to get direction ratios, divide by the distance to get direction cosines, and you have fully described which way the line points. This article builds that one calculation carefully, connects it to the vector PQ→\overrightarrow{PQ} you already know from Vector Algebra, and shows its most useful application — proving three points are collinear without drawing a single picture. Once this is automatic, writing the equation of a line through two points becomes a two-line exercise, and later topics such as the angle between two lines or a line and a plane become routine substitutions into a formula you already trust.

The core insight

The direction cosines of the line through P(x1,y1,z1)P(x_1,y_1,z_1) and Q(x2,y2,z2)Q(x_2,y_2,z_2) are the coordinate differences (x2−x1, y2−y1, z2−z1)(x_2-x_1,\,y_2-y_1,\,z_2-z_1) divided by the distance PQPQ.

The core idea

Let P(x1,y1,z1)P(x_1, y_1, z_1) and Q(x2,y2,z2)Q(x_2, y_2, z_2) be two given points, and consider the directed line from PP to QQ.

Step 1 — direction ratios. Subtract the coordinates of PP from QQ:

a=x2−x1,b=y2−y1,c=z2−z1a = x_2 - x_1, \qquad b = y_2 - y_1, \qquad c = z_2 - z_1

where: a,b,ca, b, c are the direction ratios of PQPQ — they are exactly the components of the vector PQ→=(x2−x1)ı^+(y2−y1)ȷ^+(z2−z1)k^\overrightarrow{PQ} = (x_2-x_1)\hat\imath + (y_2-y_1)\hat\jmath + (z_2-z_1)\hat k, telling you how far to move along each axis to travel from PP to QQ.

Step 2 — normalise. Direction ratios are not unit-length, so divide each by the distance PQPQ:

PQ=(x2−x1)2+(y2−y1)2+(z2−z1)2PQ = \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2 + (z_2-z_1)^2}
l=x2−x1PQ,m=y2−y1PQ,n=z2−z1PQl = \frac{x_2-x_1}{PQ}, \qquad m = \frac{y_2-y_1}{PQ}, \qquad n = \frac{z_2-z_1}{PQ}

where: l,m,nl, m, n are the direction cosines, satisfying l2+m2+n2=1l^2+m^2+n^2 = 1 by construction, since they are the components of the unit vector PQ^=PQ→/∣PQ→∣\hat{PQ} = \overrightarrow{PQ}/|\overrightarrow{PQ}|. A quick but important check: reversing the direction — going from QQ to PP instead of PP to QQ — flips the sign of every direction ratio and every direction cosine. This matches the general rule that a line's direction cosines are fixed only up to an overall sign; a line has no built-in "forward," so both (l,m,n)(l,m,n) and (−l,−m,−n)(-l,-m,-n) describe the same line. The figure below shows the geometry: the position vectors of PP and QQ from the origin, and the difference vector PQ→\overrightarrow{PQ} whose components are the direction ratios.

Figure
Two points P and Q in space joined by a directed segment, with the vector PQ shown as the difference of position vectors and its components labelled as the direction ratios
Direction ratios of PQ = components of the vector PQ z-ish x-ish O P (x1, y1, z1) Q (x2, y2, z2) PQ vector direction ratios (a, b, c) = (x2 - x1, y2 - y1, z2 - z1) divide by distance PQ to get direction cosines l, m, n

There is really only one new computation to learn here — everything else is a direct carry-over from Vector Algebra, where the difference of two position vectors and the unit vector along it are already familiar ideas. Once you have the direction cosines (or even just the direction ratios) of a line through a known point, you can immediately write the vector or Cartesian equation of that line — this construction is the standard first step in most Three-Dimensional Geometry problems.

Derivation ADirection cosines of the line joining two given points

The goal is to start from nothing but the coordinates of two points P(x1,y1,z1)P(x_1,y_1,z_1) and Q(x2,y2,z2)Q(x_2,y_2,z_2) and arrive at a normalised triple (l,m,n)(l,m,n) satisfying l2+m2+n2=1l^2+m^2+n^2=1 that fully specifies the direction of line PQPQ, using only the distance formula and basic algebra — no calculus and no assumed angle data.

Step 1. Form the direction ratios by subtracting the coordinates of PP from those of QQ, in a fixed, consistent order: a=x2−x1a = x_2-x_1, b=y2−y1b = y_2-y_1, c=z2−z1c = z_2-z_1. These three numbers are proportional to the direction cosines but are not themselves unit-length; they are simply the components of PQ→\overrightarrow{PQ}.

Step 2. Compute the distance PQPQ using the three-dimensional distance formula, PQ=a2+b2+c2PQ = \sqrt{a^2+b^2+c^2}. This is the length of the vector PQ→\overrightarrow{PQ} and is always positive, since P≠QP \ne Q.

Step 3. Divide each direction ratio by PQPQ: l=a/PQl = a/PQ, m=b/PQm = b/PQ, n=c/PQn = c/PQ. Geometrically this rescales PQ→\overrightarrow{PQ} to unit length without changing its direction, which is exactly what a direction cosine is meant to capture.

Step 4. Verify the defining identity. Squaring and adding, l2+m2+n2=a2+b2+c2PQ2=PQ2PQ2=1l^2+m^2+n^2 = \dfrac{a^2+b^2+c^2}{PQ^2} = \dfrac{PQ^2}{PQ^2} = 1, confirming (l,m,n)(l,m,n) is a genuine set of direction cosines. This identity is the standard self-check after every such computation.

Worked example

Problem. Find the direction cosines of the line joining A(2,3,−1)A(2, 3, -1) and B(5,−1,11)B(5, -1, 11), and use the same method to check whether A(1,2,3)A(1,2,3), B′(4,0,4)B'(4,0,4), C(−2,4,2)C(-2,4,2) are collinear.

Step 1. Direction ratios of ABAB: subtract coordinates of AA from BB, giving a=5−2=3a = 5-2=3, b=−1−3=−4b=-1-3=-4, c=11−(−1)=12c=11-(-1)=12.

Step 2. Distance AB=32+(−4)2+122=9+16+144=169=13AB = \sqrt{3^2+(-4)^2+12^2} = \sqrt{9+16+144} = \sqrt{169} = 13.

Step 3. Direction cosines: l=313l = \dfrac{3}{13}, m=−413m = \dfrac{-4}{13}, n=1213n = \dfrac{12}{13}. Check: l2+m2+n2=9+16+144169=169169=1l^2+m^2+n^2 = \dfrac{9+16+144}{169} = \dfrac{169}{169} = 1. ✓

Step 4. For the collinearity check, find direction ratios of AB′AB' and ACAC from the common vertex AA: AB′=(4−1, 0−2, 4−3)=(3,−2,1)AB' = (4-1,\,0-2,\,4-3) = (3,-2,1) and AC=(−2−1, 4−2, 2−3)=(−3,2,−1)AC = (-2-1,\,4-2,\,2-3) = (-3,2,-1). Since (−3,2,−1)=−1×(3,−2,1)(-3,2,-1) = -1\times(3,-2,1), the two sets of direction ratios are proportional, so AB′AB' and ACAC are parallel and share point AA — hence AA, B′B', CC are collinear.

Final answer: direction cosines of ABAB are (313,−413,1213)\left(\dfrac{3}{13}, \dfrac{-4}{13}, \dfrac{12}{13}\right), and A(1,2,3)A(1,2,3), B′(4,0,4)B'(4,0,4), C(−2,4,2)C(-2,4,2) are collinear.

Competitive stretch

Step 5. The same setup lets you find the angle a line makes with the coordinate axes almost for free. If ABAB makes angles α,β,γ\alpha, \beta, \gamma with the xx-, yy-, zz-axes respectively, then cos⁡α=l=3/13\cos\alpha = l = 3/13, cos⁡β=m=−4/13\cos\beta = m = -4/13, cos⁡γ=n=12/13\cos\gamma = n = 12/13 — the direction cosines are literally these cosines by definition, so no extra work is needed once (l,m,n)(l,m,n) is known. Since mm is negative, β\beta is obtuse (between 90°90° and 180°180°), meaning ABAB leans away from the positive yy-axis; α\alpha and γ\gamma, both from positive cosines, are acute.

Common traps

  • Subtracting coordinates in the wrong order. PQ→\overrightarrow{PQ} has direction ratios (x2−x1,y2−y1,z2−z1)(x_2-x_1, y_2-y_1, z_2-z_1), not (x1−x2,… )(x_1-x_2, \dots) — reversing the order flips every sign, which matters when you later use these ratios in the equation of the line.
  • Forgetting to normalise. Direction ratios from two points are not direction cosines until divided by PQPQ; stopping one step early is a very common half-mark loss.
  • Using the collinearity shortcut incorrectly. Three points are collinear only when the direction ratios of two segments sharing a common vertex are proportional — always compute both segments from the same point (e.g. ABAB and ACAC, not ABAB and BCBC mixed inconsistently).
  • Sign errors with negative coordinates. Always recompute l2+m2+n2l^2+m^2+n^2 as a check; it must equal 11 exactly.
  • Mixing up direction cosines with the angle itself. l,m,nl, m, n are the cosines of the angles the line makes with the axes, not the angles themselves — a negative direction cosine simply means that particular angle is obtuse, not that the calculation went wrong.

Ask the tutor: Want a fresh pair of points to find direction cosines for, or a three-point collinearity check to practice on your own?

Why do we divide by PQ instead of just using the direction ratios directly?

Direction ratios alone tell you the line's orientation but not in a standardised form — any scalar multiple of a valid triple works equally well as a direction ratio set. Direction cosines fix this by forcing l2+m2+n2=1l^2+m^2+n^2=1, so every line has one (up to sign) unique normalised triple. This standard form is what later formulas, such as the angle between two lines or the equation of a line, are built to expect.

Does it matter whether I compute P minus Q or Q minus P?

It changes the sign of every direction ratio and direction cosine, but not the line itself — a line has no inherent forward direction, so (l,m,n)(l,m,n) and (−l,−m,−n)(-l,-m,-n) describe the same line equally well. What does matter is staying consistent within a single problem, especially when comparing direction ratios of two different segments for a collinearity or parallelism check.

If the direction ratios of AB and AC are proportional, could A, B, C still fail to be collinear?

No — if AB→\overrightarrow{AB} and AC→\overrightarrow{AC} are scalar multiples of each other, they point along the same line through AA, and since both B and C then lie on that line through the common point A, all three points must be collinear. This is exactly the vector fact that two proportional (parallel) vectors sharing a point define a single line, not two.

Before this

Where this leads