Fundamentholfundamenthol

Lines in Space

MathsThree Dimensional GeometryFor JEE aspirants

A straight line in space is fixed by a point on it and a direction. That direction is measured by direction cosines or direction ratios . 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
  1. Direction cosines: , , , with
  2. From direction ratios: (same pattern for and )
  3. Direction ratios of : , ,
  4. Angle between lines:
  5. Perpendicular: ; parallel:
  6. Projection of on a line:
  7. Symmetric form: ; vector form:
  8. Line of intersection of two planes is parallel to
  9. Skew lines:
  10. Parallel lines:

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 , , are called the direction cosines of the line. They are denoted by , , :

Direction angles and direction cosines of a line A directed line O P runs from the origin to the far corner of a dashed box whose edges lie along the x, y and z axes. It makes angle alpha with the positive x-axis, beta with the positive y-axis and gamma with the positive z-axis, each drawn as an arc in the plane containing O P and that axis. Their cosines l equals cos alpha, m equals cos beta and n equals cos gamma are the direction cosines. A parallel directed line A B has the same direction angles. X Y Z α β γ O P A B Direction cosines l = cos α m = cos β n = cos γ
Figure 1: Direction angles , , of a directed line. The direction cosines are , , , and a parallel line shares them.

If the direction of the line is reversed, the angles become , , and the direction cosines become , , . So an undirected line has two sets of direction cosines that differ only in sign.

AxisAngles with x, y, z axesDirection cosines
x-axis
y-axis
z-axis

Relation between the direction cosines

Let be any line through the origin with direction cosines , , . Let and . Then

From draw , , perpendicular to the coordinate axes, so that , , and , , .

From the right triangle (Figure 2), , so . In the same way, triangles and give and . Putting these in (1):

Proof that l squared plus m squared plus n squared equals 1 Point P with coordinates x, y, z is at distance r from the origin and is the far corner of a dashed box with edges x, y and z along the axes. The perpendicular from P to the z-axis meets it at C, giving a shaded right triangle O C P with the right angle at C and angle gamma at O, so z equals n r. Similarly x equals l r and y equals m r. X Y Z γ O C P(x, y, z) z r x y cos γ = z / r ⇒ z = nr similarly x = lr, y = mr
Figure 2: In right triangle , , so ; likewise , , which gives .
  • If lies on a line through with direction cosines and , then .
  • The point at distance from along a line with direction cosines is .
  • is a unit vector parallel to the line.
Solved Example 1
If a line makes angles , , with the coordinate axes, prove that .
Solution:

Since the line makes angles , , with the axes, , , are its direction cosines, so .

In the same way, using , we get .

2. Direction Ratios of a Line

If , , are three numbers proportional to the direction cosines , , of a straight line, then , , are called the direction ratios of the line. They are also called direction numbers or direction components.

By definition, (say), so , , . Then

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: , , is also a set of direction ratios for any .
  • If are direction ratios of a line , then is a vector parallel to .
  • 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 are the direction ratios of a line, find its direction cosines.
Solution:

.

So the direction cosines are , or, for the opposite direction, .

3. Direction Cosines of the Line Joining Two Points

The direction ratios of the line joining and are , and . Dividing by gives the direction cosines:

Direction ratios and direction cosines of the line joining two points P x1 y1 z1 and Q x2 y2 z2 are opposite corners of a dashed box with edges parallel to the axes. Going from P to Q along three box edges takes steps a equals x2 minus x1 parallel to the x-axis, b equals y2 minus y1 parallel to the y-axis and c equals z2 minus z1 parallel to the z-axis, each at right angles to the next. These are direction ratios of P Q, and dividing each by the length P Q gives the direction cosines. X Y Z P(x1, y1, z1) Q(x2, y2, z2) a = x2 − x1 b = y2 − y1 c = z2 − z1 Direction cosines of PQ l = a/PQ m = b/PQ n = c/PQ
Figure 3: Direction ratios of are the axis steps , , ; dividing by gives the direction cosines.
Solved Example 3
Find the direction ratios and direction cosines of the line joining the points and .
Solution:

Direction ratios of are , or simply .

, so .

Direction cosines are .

Solved Example 4
Find the direction cosines of the two lines which are connected by the relations and .
Solution:

From the first relation, ...(1). Putting this in ...(2):

So or .

Case 1: . Then , so .

Direction cosines of one line are .

Case 2: . Then , so .

Direction cosines of the other line are .

4. Angle Between Two Lines

Let be the angle between two lines whose direction cosines are and . Then

If the direction ratios are and , the angle between the lines is given by

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.

Angle between two lines in space Line L1 lies on an upper sheet and line L2 on a lower parallel sheet, so they do not meet. Through a point Q on L2 a dashed line is drawn parallel to L1. The angle theta between this dashed line and L2 is the angle between L1 and L2, which equals the angle between their direction vectors. L1 L2 θ Q θ = angle between the directions b1 and b2 parallel to L1
Figure 4: The angle between two lines, even non-intersecting ones, is the angle between their directions. Draw a parallel to through a point of and measure there.

Sine of the angle

Conditions for perpendicular and parallel lines

Lines areUsing direction cosinesUsing direction ratios
Perpendicular ()
Parallel ()

The parallel condition comes from : the sum holds only when , and . Two parallel lines therefore have the same direction cosines.

A line perpendicular to both lines has direction ratios proportional to , , . 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 and are perpendicular.
Solution:

Therefore the lines are perpendicular.

Solved Example 6
Find the angle between the lines whose direction cosines are and .
Solution:

So , and the acute angle between the lines is .

Solved Example 7
Find the angle between any two diagonals of a cube.
Solution:

Take a cube of side with one vertex at and the edges through along the axes: , , , , , , . The four diagonals are , , and .

Angle between two diagonals of a cube Cube of side a with O at the origin and vertices A, B, C on the axes. The four body diagonals are O E, A D, C F and G B, with direction ratios 1 1 1, minus 1 1 1, 1 1 minus 1 and minus 1 1 minus 1. The angle theta between diagonals O E and A D satisfies cos theta equals one third. X Y Z θ O A B C D E F G Direction ratios OE: 1, 1, 1 AD: −1, 1, 1 CF: 1, 1, −1 GB: −1, 1, −1 cos θ = 1/3
Figure 11: The four diagonals of a cube have direction ratios . Any two of them meet at an angle .

Direction ratios of are , or , so its direction cosines are .

Direction ratios of are , or , so its direction cosines are .

Similarly, and have direction ratios and .

For and : , so . Any other pair gives 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 be the tetrahedron with at the origin and , , . Let and . We must prove .

Direction ratios of are and of are . Since :

...(1)

Since : ...(2)

Adding (1) and (2), the terms , , cancel and we get

Direction ratios of are and of are . Hence .

5. Projection of a Line Segment on a Line

The projection of the segment joining and on a line whose direction cosines are is

This is , where is the angle between and the line, because the direction cosines of are , , .

Projection of a line segment on a line Segment P Q makes angle theta with line L whose direction cosines are l, m, n. Perpendiculars from P and Q meet L at P prime and Q prime. The projection P prime Q prime equals P Q cos theta, which equals the modulus of l times x2 minus x1 plus m times y2 minus y1 plus n times z2 minus z1. L (l, m, n) θ P(x1, y1, z1) Q(x2, y2, z2) R P′ Q′ projection = P′Q′ = PQ cos θ P′Q′ = | l(x2 − x1) + m(y2 − y1) + n(z2 − z1) |
Figure 5: Projection of on a line with direction cosines is .

Vector form

The projection of on is . Here take and .

  • , and are the projections of on , and .
  • .
Solved Example 9
Find the projection of the line segment joining and on the line having direction ratios .
Solution:

Let and . Since , the direction cosines of the given line are .

Projection of

6. Equation of a Straight Line in Space

Symmetric (Cartesian) form

The equation of the straight line passing through with direction ratios is

The general point on this line is . When the denominators are the direction cosines , the point is and is its actual distance from .

Two-point form

The line passing through and is

Vector form

The line through the point with position vector and parallel to is , where is a scalar. The line through two points with position vectors and is .

Vector equation of a line The line passes through point A with position vector a and is parallel to vector b. Every point R on the line has position vector r equals a plus lambda b. Marked points show lambda equals minus 1, 0, 1, 2 and 3 along the line. λ = -1 λ = 1 λ = 2 λ = 3 b a r O A (λ = 0) R r = a + λb
Figure 7: Vector equation of a line, . Each real value of gives one point of the line; gives .

Converting between the two forms:

Special lines

LineEquation
x-axis
y-axis
z-axis
Parallel to the x-axis
Parallel to the y-axis
Parallel to the z-axis
Through the origin
A zero denominator is allowed. means together with : the line lies in the plane .
Solved Example 10
Find the equations of the straight lines through the point which are (a) parallel to the z-axis, (b) perpendicular to the z-axis.
Solution:

(a) A line parallel to the z-axis has , , , so , , . The line through is

(b) A line perpendicular to the z-axis has , so and . If it makes angle with the x-axis, then and (the sign is absorbed by the choice of ). The line is

Solved Example 11
Find the equation of the line through the points and in vector form as well as in Cartesian form.
Solution:

Let and . Then and , so .

Vector form: .

Cartesian form: , that is .

Solved Example 12
Find the coordinates of the points on the line which are at a distance of units from the point .
Solution:

The point lies on the line. Direction ratios are and , so the direction cosines are . Writing the line with direction cosines:

Any point is and . Given , .

For : . For : .

Solved Example 13
Find the coordinates of the point where the line joining the points and cuts the plane .
Solution:

Direction ratios of the line are , , , that is . Its equation is

Any point on the line is . If it lies on the plane,

The point is .

Solved Example 14
Show that the lines and intersect. Also find their point of intersection.
Solution:

Any point on the first line is and any point on the second line is . The lines intersect if and coincide for some and :

...(1)

...(2)

...(3)

Solving (1) and (2) gives , . These values also satisfy (3): .

So the lines intersect, at .

7. Perpendicular from a Point to a Line: Foot, Length and Image

Using projection

Let be a straight line passing through with direction cosines , and let be a point. If is the foot of the perpendicular from , then

Perpendicular distance, foot and image of a point in a line Line through A a b c has direction cosines l, m, n. From point P the perpendicular meets the line at the foot N. A N is the projection of A P on the line, and P N equals the square root of A P squared minus A N squared. Extending P N by an equal length beyond N gives the image P prime. line (l, m, n) P′ (image) A(a, b, c) N (foot) P(x, y, z) AP PN AN = l(x − a) + m(y − b) + n(z − c) PN = √(AP2 − AN2)
Figure 6: Foot , perpendicular distance and image of a point in a line. is the midpoint of .

Using the general point of the line

  1. Write any point of the line as .
  2. Write the direction ratios of and use line: . Solve for .
  3. Put back to get the foot . Then is the length of the perpendicular and the line is the perpendicular itself.
  4. For the image , use the fact that is the midpoint of , so .

Vector form

The foot of the perpendicular from the point with position vector to the line , and the image of that point, are

Solved Example 15
Find the perpendicular distance of the point from the straight line passing through and having direction ratios .
Solution:

Direction cosines of the line are , that is .

Perpendicular distance .

Solved Example 16
Find the length of the perpendicular from to the line .
Solution:

Method 1 (general point). Any point on the line is . Direction ratios of are . Since is perpendicular to the line with direction ratios :

So and .

Method 2 (projection). lies on the line and the direction cosines are .

projection of , and .

units, the same as Method 1.

Solved Example 17
Find the equation of the line drawn through the point to meet at right angles the line .
Solution:

Let . Any point on the given line is , so the direction ratios of are .

Since is perpendicular to the line with direction ratios :

Direction ratios of are , or . The required line is .

Solved Example 18
Find the image of the point in the line .
Solution:

Let . Any point on the line is , so the direction ratios of are .

For the foot, line:

So the foot is . Since is the midpoint of and its image :

8. Line of Intersection of Two Planes

A straight line in space can be written as the intersection of two non-parallel planes

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.

Line of intersection of two planes Two non-parallel planes a1 x plus b1 y plus c1 z plus d1 equals 0 and a2 x plus b2 y plus c2 z plus d2 equals 0 meet in a straight line L. The normals n1 and n2 of the planes are both perpendicular to L, so L is parallel to the cross product n1 cross n2. L n1 n2 a1x + b1y + c1z + d1 = 0 a2x + b2y + c2z + d2 = 0
Figure 8: A line in non-symmetric form is the intersection of two planes. It is perpendicular to both normals, so its direction is .

Step 1: Direction ratios

The line lies in both planes, so it is perpendicular to both normals: and . By cross-multiplication,

These are the components of

Step 2: A point on the line

If , the line is not parallel to the XY-plane, so it meets it. Put and solve and for and . If this fails, put or instead.

Solved Example 19
Find in symmetric form the equations of the line .
Solution:

The line is , ...(1). Let be its direction cosines. The line is perpendicular to the normals of both planes:

and

By cross-multiplication, , that is .

So the direction cosines are .

To find a point, put in (1): and . Solving, , . So lies on the line.

The symmetric form is .

Solved Example 20
Find the angle between the lines and .
Solution:

Line 1 is perpendicular to the normals and : and . So .

Line 2 is perpendicular to the normals and : and . So .

Hence .

9. Skew Lines and Shortest Distance

Relative position of two lines

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.

Parallel, intersecting and skew lines Three panels. Parallel lines lie in one plane and never meet. Intersecting lines lie in one plane and meet at exactly one point. Skew lines lie on two different parallel sheets, are not parallel, and never meet because no single plane contains both. Parallel same plane, never meet Intersecting same plane, meet at one point Skew not in one plane, never meet Only skew lines have no common plane
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.

  1. Write the lines as ...(1) and ...(2).
  2. Take on (1) and on (2).
  3. Direction ratios of are .
  4. Use (1) and (2) to get two equations in and . Solve them to get and ; then is the shortest distance.
Shortest distance between two skew lines Skew lines L1 and L2 lie in two parallel planes. The segment P Q with P on L1 and Q on L2 is perpendicular to both lines, and its length d is the shortest distance, given by the modulus of a2 minus a1 dot b1 cross b2 divided by the magnitude of b1 cross b2. L2 L1 P Q d d = |(a2 − a1) · (b1 × b2)| / |b1 × b2| PQ ⊥ L1, PQ ⊥ L2
Figure 10: The shortest distance between skew lines and is the length of their common perpendicular .

Shortest distance formula (Cartesian)

The same formula works with direction ratios in place of direction cosines.

Shortest distance formula (vector)

For and :

  • The lines are skew if , that is .
  • If this scalar triple product is (equivalently ) and the lines are not parallel, the lines intersect.
  • If a line is given in general form, first convert it to symmetric form and then apply the formula.

Distance between parallel lines

For the parallel lines and , , so the skew-lines formula cannot be used. Instead,

Solved Example 21
Find the shortest distance between the lines and . Also find the equation of the line of shortest distance.
Solution:

Any point on the first line is and on the second line is .

Direction ratios of are .

first line: ...(1)

second line: ...(2)

Solving (1) and (2), and . So and .

Shortest distance units.

Direction ratios of are , or . The line of shortest distance is , or in vector form .

Solved Example 22
Using the formula, find the shortest distance between the lines and .
Solution:

Here , , , , so .

, and .

Shortest distance units.

Solved Example 23
Find the distance between the parallel lines and .
Solution:

Here , and .

units.

Solved Example 24
A tetrahedron is formed by the planes , , and . Find the shortest distance between a pair of its opposite edges.
Solution:

The first three planes meet at . Take the pair of opposite edges (given by , ) and (given by , ).

In symmetric form, is and is . So the direction ratios are and , and is a point on .

Let the line of shortest distance have direction cosines . It is perpendicular to both edges: and . So , giving , , .

Shortest distance = projection of on this line .

By symmetry, every pair of opposite edges of this tetrahedron is apart.

Common Mistakes to Avoid

Watch out
  • Using direction ratios as direction cosines. Numbers like are direction ratios; direction cosines must satisfy .
  • Writing without dividing by the two magnitudes.
  • Treating in as a distance when are only direction ratios.
  • Reading the point from the equation with the wrong sign: belongs to a line through .
  • Calling undefined. A zero denominator simply means all along the line.
  • Using the projection formula with direction ratios instead of direction cosines.
  • Applying the skew-lines formula to parallel lines, where . 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 are the cosines of the angles a line makes with the axes, so they satisfy and are unique apart from sign. Direction ratios are any three numbers proportional to them, so a line has infinitely many sets of direction ratios.

Why do direction cosines satisfy ?

For a point at distance from the origin on the line, right triangles with the axes give , and . Substituting in gives , so the sum of squares is .

How do you find the angle between two lines in 3D?

Use with direction cosines, or divide 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 . 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 (or or ) and solve the two plane equations. Then write .

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.

Previous year questions on Lines in Space

60 questions from past papers, each with a step-by-step solution.

Show all 60 questions

Ready to master Three Dimensional Geometry?

Take a full mock test, practice concept-by-concept, and get an AI-powered rank prediction — all on Fundamenthol.