ExamSaathi learning library · School · CBSE Class 12 Mathematics 2026-27; teacher review pending · Mathematics
Three-dimensional geometry for Class 12: lines in space, angles and shortest distance
Describe a line in space by its direction cosines or direction ratios, write its vector and Cartesian equations, find the angle between two lines, tell parallel, intersecting and skew lines apart, and find the shortest distance between two lines.
Status: original pilot lesson. Teacher review is pending. It is not a complete course or official exam material.
You will learn to
- Describe a line in space by its direction cosines and direction ratios, including the line through two points.
- Write the vector and Cartesian equations of a line in space through a point parallel to a vector, or through two points.
- Find the angle between two lines in space from their direction ratios, and test whether they are perpendicular or parallel.
- Tell parallel, intersecting and skew lines apart and find the shortest distance between two lines in space.
Before you start
Recap in one line: coordinates in space and the distance formula came from the Class 11 three-dimensional geometry lesson, and the Class 12 vector algebra lesson gave position vectors, direction cosines of a vector and the dot and cross products; this lesson puts them to work on straight lines in space. Because x means multiply in this lesson, a fixed point is written A(a1, a2, a3), a moving point on a line is (u, v, w), and the number that slides a point along a line, the parameter, is called t or s. A line in space is fixed by either of two facts: one point on it together with its direction, or two points on it. Its direction can be given by a vector parallel to the line, by direction cosines or by direction ratios. Think of a cable stretched from one corner of a classroom floor to the opposite corner of the ceiling. To describe it you must say where it starts and which way it runs. Everything below is a way of writing those two facts with numbers, and then of comparing two such cables: the angle between them, and how close they come to each other.
Direction cosines and direction ratios of a line
Suppose a line is inclined at the angles alpha, beta and gamma to the positive OX, OY and OZ axes. The numbers l = cos alpha, m = cos beta and n = cos gamma are its direction cosines, and l^2 + m^2 + n^2 = 1. A line has no arrow of its own, so tracing it the other way replaces each angle by its supplement and changes the sign of all three cosines; both sets describe the same line. Direction ratios are any three numbers in the same proportion as l, m and n: 2, -1 and 2 are direction ratios of the line whose direction cosines are 2/3, -1/3 and 2/3, and so are 4, -2 and 4. A line therefore has endlessly many sets of direction ratios but only two sets of direction cosines. To turn direction ratios into direction cosines, divide each by the square root of the sum of their squares; multiplying the whole set by -1 then gives the cosines for the opposite sense. For the line through A(a1, a2, a3) and B(b1, b2, b3), the differences b1 - a1, b2 - a2 and b3 - a3 are direction ratios, and dividing them by the length AB gives direction cosines. Three different points A, B and C lie on one line exactly when the direction ratios of AB and of BC are proportional.
Vector and Cartesian equations of a line
Let a line pass through the point A with position vector a and run parallel to a nonzero vector b. A point R with position vector r lies on the line exactly when AR is a multiple of b, that is when r = a + t b for some real number t. This is the vector equation of the line. Each value of t gives one point: t = 0 gives A itself, and negative values give points on the side of A opposite to the direction of b. Let a have the components a1, a2, a3 and b the components b1, b2, b3, which are direction ratios of the line. Comparing components gives u = a1 + t b1, v = a2 + t b2 and w = a3 + t b3, and removing t gives the Cartesian (symmetric) form (u - a1)/b1 = (v - a2)/b2 = (w - a3)/b3. The numerators show a point of the line, with the signs reversed, and the denominators show its direction. A zero denominator is read as an instruction: if b3 = 0, then w stays equal to a3 all along the line. For the line through two points with position vectors a and c, take b = c - a, so r = a + t (c - a), which gives the first point at t = 0 and the second at t = 1. To test whether a given point lies on a line, find t from one coordinate and check that the same t gives the other two.
The angle between two lines
The angle between two lines is the smaller angle between their directions, from 0 to 90 degrees, because each line can be traced either way. If one line has direction ratios b1, b2, b3 and the other d1, d2, d3, then cos theta = |b1 d1 + b2 d2 + b3 d3| / (sqrt(b1^2 + b2^2 + b3^2) x sqrt(d1^2 + d2^2 + d3^2)). With direction cosines l1, m1, n1 and l2, m2, n2 the denominator is 1, so cos theta = |l1 l2 + m1 m2 + n1 n2|. The modulus keeps cos theta from being negative, so theta is never more than 90 degrees. Two special cases follow at once. The lines are perpendicular when b1 d1 + b2 d2 + b3 d3 = 0. They are parallel when one set of direction ratios is a multiple of the other, that is b1/d1 = b2/d2 = b3/d3 when no d is zero. These tests use only the directions, so in space two lines can be perpendicular without meeting, like a beam that runs across a ceiling and a floor edge that runs at right angles to it far below.
Skew lines and the shortest distance
In a plane, two different lines either meet or are parallel. In space there is a third case: skew lines, which are not parallel and never meet, so no single plane holds both. In a classroom, a floor edge that runs along the front wall and a ceiling edge that runs along a side wall are skew. The shortest distance between two lines is the length of the segment that joins them and is perpendicular to both. For the lines r = a + t b and r = c + s d, that common perpendicular runs along b cross d, so the shortest distance is |(b cross d) . (c - a)| / |b cross d|. A result of 0 means the two lines meet; a positive result means they are skew. If b cross d is the zero vector, the formula breaks down because the lines are parallel. Then, with b as the common direction, the distance is |b cross (c - a)| / |b|, which is the distance from a point of one line to the other line; if this is 0 as well, the two equations describe the same line. Lines that meet have a shortest distance of 0.
Common mistakes
1. Reading the numerators of (u - 3)/2 = (v + 1)/4 = (w - 5)/(-1) as the direction. They give the point (3, -1, 5); the direction ratios are the denominators 2, 4 and -1. 2. Taking that point as (3, 1, 5): v + 1 is v - (-1), so the coordinate is -1. 3. Calling direction ratios direction cosines without dividing by the square root of the sum of their squares. 4. Leaving out the modulus in the angle formula and reporting an obtuse angle, or leaving out the square roots in the denominator. 5. Calling two lines skew only because they are not parallel; they may still meet, so find the shortest distance, or solve for a common point, first. 6. Using the skew-line formula for parallel lines, which gives 0 divided by 0, instead of the formula for parallel lines.
A short routine
1. Write each line as r = a + t b; from a Cartesian form, read the point from the numerators with the signs reversed and the direction from the denominators. 2. For direction cosines, divide the direction ratios by the square root of the sum of their squares. 3. For the angle, use cos theta = |b . d| / (|b| |d|); a zero dot product means perpendicular lines. 4. For lines r = a + t b and r = c + s d with proportional directions b and d, the lines are parallel: use |b cross (c - a)| / |b|. 5. Otherwise find b cross d and use |(b cross d) . (c - a)| / |b cross d|; 0 means the lines meet, and a positive answer means they are skew. 6. Check the results: l^2 + m^2 + n^2 = 1 for direction cosines, an angle between lines is at most 90 degrees, and a distance is never negative.
Worked examples
A straight cable runs from A(2, -1, 3) to B(8, 1, 6), with lengths in metres. Find direction ratios and direction cosines of the line AB, write its vector and Cartesian equations, and decide whether the point C(14, 3, 9) lies on it.
- Step 1: Direction ratios, B minus A: 8 - 2 = 6, 1 - (-1) = 2 and 6 - 3 = 3.
- Step 2: Length AB = sqrt(6^2 + 2^2 + 3^2) = sqrt(36 + 4 + 9) = sqrt(49) = 7 m, so the direction cosines are 6/7, 2/7 and 3/7 (or all three with a minus sign, for the opposite sense).
- Step 3: Vector equation, with a = 2i - j + 3k and b = 6i + 2j + 3k: r = (2i - j + 3k) + t(6i + 2j + 3k).
- Step 4: Cartesian form: (u - 2)/6 = (v + 1)/2 = (w - 3)/3.
- Step 5: For C, the first coordinate gives t = (14 - 2)/6 = 2, the second (3 + 1)/2 = 2 and the third (9 - 3)/3 = 2. All three agree, so C lies on the line.
Answer: Direction ratios 6, 2, 3 and direction cosines 6/7, 2/7, 3/7 (AB = 7 m); r = (2i - j + 3k) + t(6i + 2j + 3k), that is (u - 2)/6 = (v + 1)/2 = (w - 3)/3; C(14, 3, 9) lies on the line, at t = 2.
Find the angle between the lines r = (i + 2j - k) + t(2i - j + 2k) and (u - 3)/6 = (v + 1)/3 = (w - 5)/(-2). Then find the value of p for which the line (u + 1)/p = (v - 2)/4 = w/(-3) is perpendicular to the first line.
- Step 1: Direction ratios: 2, -1, 2 for the first line and 6, 3, -2 for the second (its denominators).
- Step 2: Sum of products: 2 x 6 + (-1) x 3 + 2 x (-2) = 12 - 3 - 4 = 5.
- Step 3: Magnitudes: sqrt(4 + 1 + 4) = 3 and sqrt(36 + 9 + 4) = 7.
- Step 4: cos theta = |5| / (3 x 7) = 5/21, about 0.2381, so theta = cos^-1(5/21), about 76.2 degrees.
- Step 5: For perpendicular lines the sum of products must be 0: 2 x p + (-1) x 4 + 2 x (-3) = 0, so 2p - 4 - 6 = 0 and p = 5.
Answer: The angle is cos^-1(5/21), about 76.2 degrees (cos theta is about 0.2381), and p = 5 makes the third line perpendicular to the first.
Find the shortest distance between the lines r = (i + 2k) + t(2i + j - k) and r = (3i + 4j + k) + s(i - j + 2k), and say whether they meet, are parallel or are skew.
- Step 1: Write the lines as r = a + t b and r = c + s d, with a = i + 2k, b = 2i + j - k, c = 3i + 4j + k and d = i - j + 2k.
- Step 2: b cross d = (1 x 2 - (-1) x (-1)) i - (2 x 2 - (-1) x 1) j + (2 x (-1) - 1 x 1) k = i - 5j - 3k.
- Step 3: |b cross d| = sqrt(1 + 25 + 9) = sqrt(35), about 5.916. It is not zero, so the lines are not parallel.
- Step 4: c - a = (3 - 1) i + (4 - 0) j + (1 - 2) k = 2i + 4j - k.
- Step 5: (b cross d) . (c - a) = 1 x 2 + (-5) x 4 + (-3) x (-1) = 2 - 20 + 3 = -15.
- Step 6: Shortest distance = |-15| / sqrt(35) = 15/sqrt(35), about 2.54 units.
Answer: The shortest distance is 15/sqrt(35), about 2.54 units. The lines are not parallel and this distance is not zero, so they never meet: they are skew.
Practice checks
- What are the direction cosines of the line through P(1, 4, -2) and Q(3, 0, 2), taken in the direction from P to Q?
- Which vector equation describes the line (u - 4)/3 = (v + 2)/(-1) = (w - 1)/2?
- What is the angle between two lines whose direction ratios are 1, 1, 0 and -3, 0, 3?
- The lines r = (i + j) + t(2i - j + 2k) and r = (4i + j + 3k) + s(4i - 2j + 4k) are parallel. What is the distance between them?
- What can you say about the lines r = (i + j) + t(i + k) and r = (3i + k) + s(i - j)?
Sources checked
- CBSE Mathematics (041), Classes XI-XII (2026-27) — Class XII Unit IV Vectors and Three-dimensional Geometry, Chapter 2 Three-dimensional Geometry
- NCERT Mathematics Part II, Class XII, Chapter 11 Three Dimensional Geometry — Direction cosines and direction ratios of a line, equation of a line in space, angle between two lines, shortest distance between two lines
- OpenStax Calculus Volume 3, 2.5 Equations of Lines and Planes in Space — Vector, parametric and symmetric equations of a line, parallel, intersecting and skew lines, and the distance between skew lines
- OpenStax Calculus Volume 3, 2.3 The Dot Product — The angle between two vectors, orthogonal vectors, and direction angles and direction cosines