A straight line in space is fixed by a point on it and a direction. That direction is measured by direction cosinesl,m,n or direction ratiosa,b,c. This page on lines in space covers how to find them, the angle between two lines, projection of a segment, the symmetric and vector equations of a line, the foot and image of a point, the line of intersection of two planes, and the shortest distance between skew lines. Lines in space are tested every year in JEE Main and JEE Advanced.
Key Formulas: Quick Reference
Direction cosines: l=cosα, m=cosβ, n=cosγ, with l2+m2+n2=1
From direction ratios: l=a2+b2+c2a (same pattern for m and n)
Line of intersection of two planes is parallel to n1×n2
Skew lines: d=∣b1×b2∣∣(a2−a1)⋅(b1×b2)∣
Parallel lines: d=∣b∣∣(a2−a1)×b∣
1. Direction Cosines of a Line
If α, β, γ are the angles which a directed line makes with the positive directions of the x, y and z axes, then cosα, cosβ, cosγ are called the direction cosines of the line. They are denoted by l, m, n:
l=cosα,m=cosβ,n=cosγ
Figure 1: Direction angles α, β, γ of a directed line. The direction cosines are l=cosα, m=cosβ, n=cosγ, and a parallel line AB shares them.
If the direction of the line is reversed, the angles become π−α, π−β, π−γ and the direction cosines become −l, −m, −n. So an undirected line has two sets of direction cosines that differ only in sign.
Axis
Angles with x, y, z axes
Direction cosines
x-axis
0∘,90∘,90∘
(1,0,0)
y-axis
90∘,0∘,90∘
(0,1,0)
z-axis
90∘,90∘,0∘
(0,0,1)
Relation between the direction cosines
Let OP be any line through the origin O with direction cosines l, m, n. Let P=(x,y,z) and OP=r. Then
OP2=x2+y2+z2=r2...(1)
From P draw PA, PB, PC perpendicular to the coordinate axes, so that OA=x, OB=y, OC=z and ∠POA=α, ∠POB=β, ∠POC=γ.
From the right triangle OCP (Figure 2), n=cosγ=rz, so z=nr. In the same way, triangles OAP and OBP give x=lr and y=mr. Putting these in (1):
r2(l2+m2+n2)=x2+y2+z2=r2⇒l2+m2+n2=1
Figure 2: In right triangle OCP, cosγ=rz, so z=nr; likewise x=lr, y=mr, which gives l2+m2+n2=1.
If P lies on a line through O with direction cosines l,m,n and OP=r, then P=(lr,mr,nr).
The point at distance r from A(x1,y1,z1) along a line with direction cosines l,m,n is (x1+lr,y1+mr,z1+nr).
li^+mj^+nk^ is a unit vector parallel to the line.
Solved Example 1
If a line makes angles α, β, γ with the coordinate axes, prove that sin2α+sin2β+sin2γ=2.
Solution:
Since the line makes angles α, β, γ with the axes, cosα, cosβ, cosγ are its direction cosines, so cos2α+cos2β+cos2γ=1.
In the same way, using cos2θ=2cos2θ−1, we get cos2α+cos2β+cos2γ=2−3=−1.
2. Direction Ratios of a Line
If a, b, c are three numbers proportional to the direction cosines l, m, n of a straight line, then a, b, c are called the direction ratios of the line. They are also called direction numbers or direction components.
By definition, al=bm=cn=k (say), so l=ak, m=bk, n=ck. Then
k2(a2+b2+c2)=l2+m2+n2=1⇒k=±a2+b2+c21
l=±a2+b2+c2a,m=±a2+b2+c2b,n=±a2+b2+c2c
The same sign, either positive or negative, is taken throughout.
Direction cosines of a line are unique (apart from reversing the sign), but direction ratios are not: ka, kb, kc is also a set of direction ratios for any k=0.
If a,b,c are direction ratios of a line L, then ai^+bj^+ck^ is a vector parallel to L.
Parallel lines have the same direction cosines. For a line that does not pass through the origin, draw a parallel line through the origin to find its direction cosines.
Solved Example 2
If 2,−3,6 are the direction ratios of a line, find its direction cosines.
Solution:
a2+b2+c2=4+9+36=7.
So the direction cosines are 72,−73,76, or, for the opposite direction, −72,73,−76.
3. Direction Cosines of the Line Joining Two Points
The direction ratios of the line PQ joining P(x1,y1,z1) and Q(x2,y2,z2) are a=x2−x1, b=y2−y1 and c=z2−z1. Dividing by PQ=(x2−x1)2+(y2−y1)2+(z2−z1)2 gives the direction cosines:
l=PQx2−x1,m=PQy2−y1,n=PQz2−z1
Figure 3: Direction ratios of PQ are the axis steps x2−x1, y2−y1, z2−z1; dividing by PQ gives the direction cosines.
Solved Example 3
Find the direction ratios and direction cosines of the line joining the points A(6,−7,−1) and B(2,−3,1).
Solution:
Direction ratios of AB are (6−2,−7+3,−1−1)=(4,−4,−2), or simply (2,−2,−1).
a2+b2+c2=4+4+1=9, so a2+b2+c2=3.
Direction cosines are (±32,∓32,∓31).
Solved Example 4
Find the direction cosines of the two lines which are connected by the relations l−5m+3n=0 and 7l2+5m2−3n2=0.
Solution:
From the first relation, l=5m−3n ...(1). Putting this in 7l2+5m2−3n2=0 ...(2):
For lines that do not meet, the angle is the angle between their directions (Figure 4). For the acute angle, take the modulus of the right-hand side.
Figure 4: The angle between two lines, even non-intersecting ones, is the angle θ between their directions. Draw a parallel to L1 through a point of L2 and measure θ there.
The parallel condition comes from sinθ=0: the sum (l1m2−l2m1)2+(m1n2−m2n1)2+(n1l2−n2l1)2=0 holds only when l1m2−l2m1=0, m1n2−m2n1=0 and n1l2−n2l1=0. Two parallel lines therefore have the same direction cosines.
A line perpendicular to both lines has direction ratios proportional to m1n2−m2n1, n1l2−n2l1, l1m2−l2m1. These are the components of the cross product of the two direction vectors, and they are used again for the line of intersection of two planes and for shortest distance.
Solved Example 5
Show that the two lines having direction ratios −1,3,2 and 2,2,−2 are perpendicular.
So θ=120∘, and the acute angle between the lines is 60∘.
Solved Example 7
Find the angle between any two diagonals of a cube.
Solution:
Take a cube of side a with one vertex at O and the edges through O along the axes: A(a,0,0), B(0,a,0), C(0,0,a), D(0,a,a), E(a,a,a), F(a,a,0), G(a,0,a). The four diagonals are OE, AD, CF and GB.
Figure 11: The four diagonals of a cube have direction ratios (±1,1,±1). Any two of them meet at an angle θ=cos−1(31).
Direction ratios of OE are a,a,a, or 1,1,1, so its direction cosines are 31,31,31.
Direction ratios of AD are −a,a,a, or −1,1,1, so its direction cosines are −31,31,31.
Similarly, CF and GB have direction ratios 1,1,−1 and −1,1,−1.
For OE and AD: cosθ=−31+31+31=31, so θ=cos−1(31). Any other pair gives ∣cosθ∣=31 as well.
Solved Example 8
If two pairs of opposite edges of a tetrahedron are mutually perpendicular, show that the third pair is also mutually perpendicular.
Solution:
Let OABC be the tetrahedron with O at the origin and A(x1,y1,z1), B(x2,y2,z2), C(x3,y3,z3). Let OA⊥BC and OB⊥CA. We must prove OC⊥BA.
Direction ratios of OA are x1,y1,z1 and of BC are x3−x2,y3−y2,z3−z2. Since OA⊥BC:
x1(x3−x2)+y1(y3−y2)+z1(z3−z2)=0 ...(1)
Since OB⊥CA: x2(x1−x3)+y2(y1−y3)+z2(z1−z3)=0 ...(2)
Adding (1) and (2), the terms x1x2, y1y2, z1z2 cancel and we get
x3(x1−x2)+y3(y1−y2)+z3(z1−z2)=0
Direction ratios of OC are x3,y3,z3 and of BA are x1−x2,y1−y2,z1−z2. Hence OC⊥BA.
5. Projection of a Line Segment on a Line
The projection of the segment joining P(x1,y1,z1) and Q(x2,y2,z2) on a line whose direction cosines are l,m,n is
P′Q′=∣l(x2−x1)+m(y2−y1)+n(z2−z1)∣
This is PQcosθ, where θ is the angle between PQ and the line, because the direction cosines of PQ are PQx2−x1, PQy2−y1, PQz2−z1.
Figure 5: Projection of PQ on a line with direction cosines l,m,n is P′Q′=PQcosθ=∣l(x2−x1)+m(y2−y1)+n(z2−z1)∣.
Vector form
The projection of a on b is a⋅b^=∣b∣a⋅b. Here take a=PQ=(x2−x1)i^+(y2−y1)j^+(z2−z1)k^ and b=li^+mj^+nk^.
l∣r∣, m∣r∣ and n∣r∣ are the projections of r on OX, OY and OZ.
r=∣r∣(li^+mj^+nk^).
Solved Example 9
Find the projection of the line segment joining (1,2,3) and (−1,4,2) on the line having direction ratios 2,3,−6.
Solution:
Let A(1,2,3) and B(−1,4,2). Since 22+32+(−6)2=7, the direction cosines of the given line are 72,73,−76.
Projection of AB=72(−1−1)+73(4−2)−76(2−3)=7−4+6+6=78
6. Equation of a Straight Line in Space
Symmetric (Cartesian) form
The equation of the straight line passing through P(x1,y1,z1) with direction ratios a,b,c is
ax−x1=by−y1=cz−z1=r
The general point on this line is (x1+ar,y1+br,z1+cr). When the denominators are the direction cosines l,m,n, the point is (x1+lr,y1+mr,z1+nr) and r is its actual distance from P.
Two-point form
The line passing through P(x1,y1,z1) and Q(x2,y2,z2) is
x2−x1x−x1=y2−y1y−y1=z2−z1z−z1
Vector form
The line through the point with position vector a and parallel to b is r=a+λb, where λ is a scalar. The line through two points with position vectors a and b is r=a+λ(b−a).
Figure 7: Vector equation of a line, r=a+λb. Each real value of λ gives one point of the line; λ=0 gives A.
A zero denominator is allowed. 0x−2=3y+1=4z means x=2 together with 3y+1=4z: the line lies in the plane x=2.
Solved Example 10
Find the equations of the straight lines through the point (a,b,c) which are (a) parallel to the z-axis, (b) perpendicular to the z-axis.
Solution:
(a) A line parallel to the z-axis has α=90∘, β=90∘, γ=0∘, so l=0, m=0, n=1. The line through (a,b,c) is
0x−a=0y−b=1z−c,that is x=a,y=b
(b) A line perpendicular to the z-axis has γ=90∘, so n=0 and l2+m2=1. If it makes angle α with the x-axis, then l=cosα and m=sinα (the sign is absorbed by the choice of α). The line is
cosαx−a=sinαy−b=0z−c,that is lx−a=my−b=0z−c
Solved Example 11
Find the equation of the line through the points (3,4,−7) and (1,−1,6) in vector form as well as in Cartesian form.
Solution:
Let A(3,4,−7) and B(1,−1,6). Then a=3i^+4j^−7k^ and b=i^−j^+6k^, so b−a=−2i^−5j^+13k^.
Vector form: r=3i^+4j^−7k^+t(−2i^−5j^+13k^).
Cartesian form: 1−3x−3=−1−4y−4=6+7z+7, that is 2x−3=5y−4=−13z+7.
Solved Example 12
Find the coordinates of the points on the line 2x−1=3y+2=6z−3 which are at a distance of 3 units from the point (1,−2,3).
Solution:
The point P(1,−2,3) lies on the line. Direction ratios are 2,3,6 and 4+9+36=7, so the direction cosines are 72,73,76. Writing the line with direction cosines:
2/7x−1=3/7y+2=6/7z−3=r
Any point is Q(1+72r,−2+73r,3+76r) and PQ=∣r∣. Given ∣r∣=3, r=±3.
For r=3: Q=(713,−75,739). For r=−3: Q=(71,−723,73).
Solved Example 13
Find the coordinates of the point where the line joining the points (2,−3,1) and (3,−4,−5) cuts the plane 2x+y+z=7.
Solution:
Direction ratios of the line are 3−2, −4+3, −5−1, that is 1,−1,−6. Its equation is
1x−2=−1y+3=−6z−1=r
Any point on the line is (r+2,−r−3,−6r+1). If it lies on the plane,
2(r+2)+(−r−3)+(−6r+1)=7⇒−5r+2=7⇒r=−1
The point is (−1+2,1−3,6+1)=(1,−2,7).
Solved Example 14
Show that the lines 2x−1=3y−2=4z−3 and 5x−4=2y−1=z intersect. Also find their point of intersection.
Solution:
Any point on the first line is P(2r+1,3r+2,4r+3) and any point on the second line is Q(5λ+4,2λ+1,λ). The lines intersect if P and Q coincide for some r and λ:
2r+1=5λ+4⇒2r−5λ=3 ...(1)
3r+2=2λ+1⇒3r−2λ=−1 ...(2)
4r+3=λ⇒4r−λ=−3 ...(3)
Solving (1) and (2) gives r=−1, λ=−1. These values also satisfy (3): −4+1=−3.
So the lines intersect, at P(−1,−1,−1).
7. Perpendicular from a Point to a Line: Foot, Length and Image
Using projection
Let AB be a straight line passing through A(a,b,c) with direction cosines l,m,n, and let P(x,y,z) be a point. If N is the foot of the perpendicular from P, then
AN=projection of AP on AB=l(x−a)+m(y−b)+n(z−c)
AP=(x−a)2+(y−b)2+(z−c)2,PN=AP2−AN2
Figure 6: Foot N, perpendicular distance PN=AP2−AN2 and image P′ of a point in a line. N is the midpoint of PP′.
Using the general point of the line
Write any point of the line lx−a=my−b=nz−c=r as N(a+lr,b+mr,c+nr).
Write the direction ratios of PN and use PN⊥ line: l(a+lr−x)+m(b+mr−y)+n(c+nr−z)=0. Solve for r.
Put r back to get the foot N. Then PN is the length of the perpendicular and the line PN is the perpendicular itself.
For the image P′, use the fact that N is the midpoint of PP′, so P′=(2xN−x,2yN−y,2zN−z).
Vector form
The foot of the perpendicular from the point with position vector p to the line r=a+λb, and the image q of that point, are
f=a+∣b∣2(p−a)⋅bb,q=2f−p
Solved Example 15
Find the perpendicular distance of the point P(0,−1,3) from the straight line passing through A(1,−3,2) and having direction ratios 1,2,2.
Solution:
Direction cosines of the line are 1+4+41,32,32, that is 31,32,32.
Find the length of the perpendicular from P(2,−3,1) to the line 2x+1=3y−3=−1z+2.
Solution:
Method 1 (general point). Any point on the line is Q(2r−1,3r+3,−r−2). Direction ratios of PQ are 2r−3,3r+6,−r−3. Since PQ is perpendicular to the line with direction ratios 2,3,−1:
2(2r−3)+3(3r+6)−(−r−3)=0⇒14r+15=0⇒r=−1415
So Q=(−722,−143,−1413) and PQ2=(1472)2+(1439)2+(1427)2=1967434=14531.
Method 2 (projection).R(−1,3,−2) lies on the line and the direction cosines are 142,143,−141.
RQ= projection of RP=142(3)+3(−6)−1(3)=−1415, and PR2=32+62+32=54.
PQ=PR2−RQ2=54−14225=14531 units, the same as Method 1.
Solved Example 17
Find the equation of the line drawn through the point (1,0,2) to meet at right angles the line 3x+1=−2y−2=−1z+1.
Solution:
Let P(1,0,2). Any point on the given line is Q(3r−1,−2r+2,−r−1), so the direction ratios of PQ are 3r−2,−2r+2,−r−3.
Since PQ is perpendicular to the line with direction ratios 3,−2,−1:
3(3r−2)−2(−2r+2)−(−r−3)=0⇒14r−7=0⇒r=21
Direction ratios of PQ are −21,1,−27, or 1,−2,7. The required line is 1x−1=−2y=7z−2.
Solved Example 18
Find the image of the point (1,6,3) in the line 1x=2y−1=3z−2.
Solution:
Let P(1,6,3). Any point on the line is N(λ,2λ+1,3λ+2), so the direction ratios of PN are λ−1,2λ−5,3λ−1.
For the foot, PN⊥ line: (λ−1)+2(2λ−5)+3(3λ−1)=0⇒14λ−14=0⇒λ=1
So the foot is N(1,3,5). Since N is the midpoint of P and its image P′:
P′=(2⋅1−1,2⋅3−6,2⋅5−3)=(1,0,7)
8. Line of Intersection of Two Planes
A straight line in space can be written as the intersection of two non-parallel planes
a1x+b1y+c1z+d1=0,a2x+b2y+c2z+d2=0
This is called the non-symmetric (general) form of the line. To write it in symmetric form we need its direction ratios and one point on it.
Figure 8: A line in non-symmetric form is the intersection of two planes. It is perpendicular to both normals, so its direction is n1×n2.
Step 1: Direction ratios
The line lies in both planes, so it is perpendicular to both normals: a1l+b1m+c1n=0 and a2l+b2m+c2n=0. By cross-multiplication,
b1c2−b2c1l=c1a2−c2a1m=a1b2−a2b1n
These are the components of
n1×n2=i^a1a2j^b1b2k^c1c2
Step 2: A point on the line
If a1b2−a2b1=0, the line is not parallel to the XY-plane, so it meets it. Put z=0 and solve a1x+b1y+d1=0 and a2x+b2y+d2=0 for x and y. If this fails, put y=0 or x=0 instead.
Solved Example 19
Find in symmetric form the equations of the line 3x+2y−z−4=0=4x+y−2z+3.
Solution:
The line is 3x+2y−z−4=0, 4x+y−2z+3=0 ...(1). Let l,m,n be its direction cosines. The line is perpendicular to the normals of both planes:
3l+2m−n=0 and 4l+m−2n=0
By cross-multiplication, −4+1l=−4+6m=3−8n, that is −3l=2m=−5n=9+4+251=381.
So the direction cosines are −383,382,−385.
To find a point, put z=0 in (1): 3x+2y−4=0 and 4x+y+3=0. Solving, x=−2, y=5. So (−2,5,0) lies on the line.
The symmetric form is −3x+2=2y−5=−5z.
Solved Example 20
Find the angle between the lines x−3y−4=0,4y−z+5=0 and x+3y−11=0,2y−z+6=0.
Solution:
Line 1 is perpendicular to the normals (1,−3,0) and (0,4,−1): l1−3m1=0 and 4m1−n1=0. So 3l1=1m1=4n1.
Line 2 is perpendicular to the normals (1,3,0) and (0,2,−1): l2+3m2=0 and 2m2−n2=0. So −3l2=1m2=2n2.
Two lines in space are parallel (coplanar and never meeting), intersecting (coplanar and meeting at one point) or skew. Skew lines are lines that are neither parallel nor intersecting, so no plane contains both of them.
Figure 9: Relative positions of two lines in space. Parallel and intersecting lines are coplanar; skew lines are neither parallel nor intersecting.
Line of shortest distance
For two skew lines, the straight line that is perpendicular to each of them is called the line of shortest distance, and the length it intercepts between the two lines is the shortest distance.
Write the lines as l1x−x1=m1y−y1=n1z−z1=r1 ...(1) and l2x−x2=m2y−y2=n2z−z2=r2 ...(2).
Take P(x1+l1r1,y1+m1r1,z1+n1r1) on (1) and Q(x2+l2r2,y2+m2r2,z2+n2r2) on (2).
Direction ratios of PQ are (l1r1+x1−x2−l2r2,m1r1+y1−y2−m2r2,n1r1+z1−z2−n2r2).
Use PQ⊥ (1) and PQ⊥ (2) to get two equations in r1 and r2. Solve them to get P and Q; then PQ is the shortest distance.
Figure 10: The shortest distance between skew lines L1 and L2 is the length d of their common perpendicular PQ.
A tetrahedron is formed by the planes y+z=0, x+z=0, x+y=0 and x+y+z=3a. Find the shortest distance between a pair of its opposite edges.
Solution:
The first three planes meet at O(0,0,0). Take the pair of opposite edges OA (given by y+z=0, x+z=0) and BC (given by x+y=0, x+y+z=3a).
In symmetric form, OA is 1x=1y=−1z and BC is 1x=−1y=0z−3a. So the direction ratios are 1,1,−1 and 1,−1,0, and C′(0,0,3a) is a point on BC.
Let the line of shortest distance have direction cosines l,m,n. It is perpendicular to both edges: l+m−n=0 and l−m=0. So 1l=1m=2n, giving l=61, m=61, n=62.
Shortest distance = projection of OC′ on this line =0⋅61+0⋅61+3a⋅62=66a=6a.
By symmetry, every pair of opposite edges of this tetrahedron is 6a apart.
Common Mistakes to Avoid
Watch out
Using direction ratios as direction cosines. Numbers like 1,−1,−1 are direction ratios; direction cosines must satisfy l2+m2+n2=1.
Writing cosθ=a1a2+b1b2+c1c2 without dividing by the two magnitudes.
Treating r in ax−x1=by−y1=cz−z1=r as a distance when a,b,c are only direction ratios.
Reading the point from the equation with the wrong sign: 2x+3 belongs to a line through x=−3.
Calling 0z−c undefined. A zero denominator simply means z=c all along the line.
Using the projection formula with direction ratios instead of direction cosines.
Applying the skew-lines formula to parallel lines, where b1×b2=0. Use the parallel-lines formula instead.
Forgetting to check the third equation when testing whether two lines intersect.
Frequently Asked Questions
What is the difference between direction cosines and direction ratios?
Direction cosines l,m,n are the cosines of the angles a line makes with the axes, so they satisfy l2+m2+n2=1 and are unique apart from sign. Direction ratios a,b,c are any three numbers proportional to them, so a line has infinitely many sets of direction ratios.
Why do direction cosines satisfy l2+m2+n2=1?
For a point P(x,y,z) at distance r from the origin on the line, right triangles with the axes give x=lr, y=mr and z=nr. Substituting in x2+y2+z2=r2 gives r2(l2+m2+n2)=r2, so the sum of squares is 1.
How do you find the angle between two lines in 3D?
Use cosθ=l1l2+m1m2+n1n2 with direction cosines, or divide a1a2+b1b2+c1c2 by the product of the magnitudes when you have direction ratios. Take the modulus for the acute angle. The same formula works for skew lines because only the directions matter.
What are skew lines?
Skew lines are two lines in space that are neither parallel nor intersecting. Because they never meet and do not point the same way, no single plane can contain both. They exist only in three dimensions; in a plane, any two non-parallel lines must meet.
How do you find the shortest distance between two skew lines?
Write both lines in vector form and use d=∣b1×b2∣∣(a2−a1)⋅(b1×b2)∣. If you also need the line of shortest distance, take general points on both lines, make their join perpendicular to both directions and solve for the two parameters.
How do you convert a line from non-symmetric form to symmetric form?
A line given by two plane equations has direction ratios equal to the cross product of the two normals, found by cross-multiplication. For a point, put z=0 (or y=0 or x=0) and solve the two plane equations. Then write ax−x1=by−y1=cz−z1.
How important are lines in space for JEE Main?
Direction ratios, angle between lines, equation of a line, skew lines and shortest distance are listed explicitly in the JEE Main syllabus, and questions on the foot or image of a point and on intersecting lines are frequent. Most can be solved in under two minutes once the general-point method is automatic.
What should JEE Advanced aspirants practise in this concept?
JEE Advanced combines ideas: lines given as intersections of planes, shortest distance between edges of a solid, conditions for lines to intersect with unknown parameters, and images of a point in a line. Practise converting between Cartesian and vector forms quickly, since multi-correct options often hide the same line in different forms.