On this page
You have two points P and Q, a line with known direction, and you need the length of the shadow PQ casts on that line. One formula does it, and once you see where it comes from, you won't need to memorise it.
What is the projection of a line segment on a line?
Drop a perpendicular from P to the line and another from Q. The two feet of those perpendiculars mark a piece of the line. That piece is the projection of PQ, and its length is what the question asks for.
The NCERT Class 12 textbook (Chapter 10, Vector Algebra, section 10.6.2) defines it for a vector AB making an angle θ with a directed line: the projection has magnitude |AB| |cos θ|. The same chapter states that if p̂ is the unit vector along a line, the projection of a vector a on that line is a · p̂.
What is the formula using direction cosines?
If the line has direction cosines l, m, n, and P = (x₁, y₁, z₁), Q = (x₂, y₂, z₂), then:
Projection of PQ on the line = |(x₂ − x₁)l + (y₂ − y₁)m + (z₂ − z₁)n|
The absolute value is there because a length cannot be negative. Swap P and Q and every bracket changes sign, but the length stays the same.
Why does the formula work?
Each of the three steps rests on a result in NCERT.
The vector PQ is (x₂ − x₁)î + (y₂ − y₁)ĵ + (z₂ − z₁)k̂.
A line with direction cosines l, m, n has unit vector lî + mĵ + nk̂. NCERT's Three Dimensional Geometry chapter defines l, m, n as the cosines of the angles the line makes with the x, y and z-axes, with l² + m² + n² = 1, which is why this vector has length 1.
Projection on a line = PQ · (unit vector along the line). In components, a dot product is a₁b₁ + a₂b₂ + a₃b₃ (Vector Algebra, section 10.6.1). Multiply component by component, take the absolute value, and you have the formula.
Because the unit vector has length 1, the dot product equals |PQ| cos θ. So the projection is never longer than PQ: it equals PQ when they are parallel and 0 when perpendicular.
Worked example: how do you find the projection of PQ?
Find the length of the projection of the segment joining P(1, 2, 3) and Q(4, 6, −2) on a line with direction ratios 2, −1, 2.
Turn ratios into cosines. √(2² + (−1)² + 2²) = √9 = 3, so l, m, n = 2/3, −1/3, 2/3. (NCERT works a near-identical set, 2, −1, −2, as Example 2 in its 3D geometry chapter.)
Find the differences. x₂ − x₁ = 3, y₂ − y₁ = 4, z₂ − z₁ = −5.
Multiply and add. 3(2/3) + 4(−1/3) + (−5)(2/3) = 2 − 4/3 − 10/3 = −8/3.
Take the absolute value. Projection = 8/3.
Check. PQ = √(9 + 16 + 25) = √50, about 7.07. Since 8/3 is about 2.67, the answer is smaller than PQ, as it should be.
A useful special case: the projections of PQ on the x, y and z-axes are just |x₂ − x₁|, |y₂ − y₁| and |z₂ − z₁|, because the axes have direction cosines (1, 0, 0), (0, 1, 0) and (0, 0, 1). For a refresher on getting l, m, n from two points or from ratios, see our step-by-step guide to finding direction cosines of a line in 3D.
What mistakes cost marks on this question?
Before you write the final answer, run through this checklist:
Ratios used as cosines. If l² + m² + n² is not 1, you have ratios. Divide each one by √(a² + b² + c²).
Dropped absolute value. A negative answer for a length means you forgot the modulus. The sign only tells you whether PQ points with the line or against it.
Mixed-up pairing. l goes with the x-difference, m with y, n with z. Write the three products in a column so you can't mix them up.
No size check. Compare your answer with PQ. It can never be bigger.
To practise that link, work through the angle between two lines from direction ratios, then see how projection onto a common perpendicular gives the shortest distance between skew lines.
If you keep landing on the right method but the wrong number, try similar problems in the Fermi Problem Library. Its step-by-step solver explains the reasoning rather than printing an answer, so you can see exactly which step went wrong. If the dot product itself still feels shaky, the vectors and 3D geometry lessons in the Fermi Concept Library are a good place to rebuild it.



