Vectors, the Dot & Cross Products & Solid Coordinate Geometry

direction cosines

If you want to say which way a line points in space, one tidy way is to report the angle it makes with each of the three axes. The cosines of those three angles are the direction cosines — three numbers that encode pure direction, the spatial analogue of a compass bearing. They are nothing more than the components of a unit vector along the line, dressed up in the language of angles.

Let a line (or a vector) make angles alpha, beta, gamma with the positive x, y, z axes respectively. The direction cosines are l = cos alpha, m = cos beta, n = cos gamma. If the vector is v = (a, b, c) with length |v| = sqrt(a^2 + b^2 + c^2), then l = a/|v|, m = b/|v|, n = c/|v| — which are exactly the components of the unit vector v-hat. A defining identity always holds: l^2 + m^2 + n^2 = 1, because (l, m, n) is a unit vector. Closely related are direction RATIOS (or direction numbers): any triple proportional to (l, m, n), such as the raw components (a, b, c) before dividing by the length. Direction ratios are easier to read off and are normalised to direction cosines only when you need the unit-length version.

Direction cosines give a coordinate-free handle on the direction of a line, used to write the equations of lines, to test parallelism (same direction cosines, up to sign), and to find angles between lines via the dot product: cos theta = |l_1 l_2 + m_1 m_2 + n_1 n_2|. A point worth flagging: a direction and its exact opposite share the same line but have direction cosines of opposite sign — (l, m, n) and (-l, -m, -n) describe the two ways to travel along one line. So direction cosines pin down a direction including its sense, whereas the bare line is happy with either sense.

The vector v = (2, -1, 2) has length |v| = sqrt(4 + 1 + 4) = 3, so its direction cosines are l = 2/3, m = -1/3, n = 2/3. Check: (2/3)^2 + (-1/3)^2 + (2/3)^2 = 4/9 + 1/9 + 4/9 = 1. The direction ratios (2, -1, 2) point the same way without the normalising step.

The components of the unit direction vector; their squares sum to one.

Direction cosines must satisfy l^2 + m^2 + n^2 = 1 — if a triple does not, it is a set of direction ratios, not direction cosines, and you must divide by sqrt(a^2 + b^2 + c^2) to get the true cosines.

Also called
direction angles方向角