In short

Any vector in 3D space can be written as a_1\hat{i} + a_2\hat{j} + a_3\hat{k}, where \hat{i}, \hat{j}, \hat{k} are unit vectors along the coordinate axes. The numbers a_1, a_2, a_3 are the vector's components. The angles this vector makes with the three axes are captured by direction cosines, and these cosines always satisfy \cos^2\alpha + \cos^2\beta + \cos^2\gamma = 1.

Point a torch at a wall. The beam hits the wall and makes a bright spot. Now tilt the torch upward at an angle. The spot on the wall does not move straight up — it moves both upward and sideways (if you tilted at an angle to the wall). One tilt, two effects.

This is what "resolving into components" means. A single vector — the direction the torch points — has an effect along the horizontal direction and a separate effect along the vertical direction. Breaking it apart into these separate effects is resolution, and it is the single most useful technique in all of vector mathematics.

Why? Because once you have components, every vector operation reduces to ordinary arithmetic. Adding two vectors becomes adding their x-components and their y-components separately. Finding magnitude becomes the Pythagorean theorem. Finding direction becomes trigonometry. The geometry is still there — it is just expressed as numbers you can compute.

The coordinate axes and unit vectors

Fix a coordinate system in three-dimensional space: three mutually perpendicular axes, x, y, and z. Along each axis, mark a unit vector — a vector of length 1 pointing in the positive direction:

The three unit vectors i-hat, j-hat, k-hat along coordinate axesA 3D coordinate system with i-hat pointing to the right along the x-axis, j-hat pointing up along the y-axis, and k-hat pointing out of the page along the z-axis drawn in perspective. î (x) ĵ (y) k̂ (z) O
The three unit vectors. Each has magnitude 1 and points along one coordinate axis. Together they form a basis — every vector in 3D space can be written as a combination of these three.

These three unit vectors are the building blocks. Any vector in space can be written as a sum of scaled copies of \hat{i}, \hat{j}, and \hat{k}.

Resolution into components

Take a vector \vec{a} in three-dimensional space. Drop perpendiculars from the head of \vec{a} onto each coordinate axis. The projections onto the x-, y-, and z-axes have lengths a_1, a_2, a_3 (with sign — negative if the projection points in the negative direction). Then:

\vec{a} = a_1\hat{i} + a_2\hat{j} + a_3\hat{k}

The numbers a_1, a_2, a_3 are called the components (or coordinates) of the vector \vec{a}. The expression a_1\hat{i} + a_2\hat{j} + a_3\hat{k} is the component form of the vector.

In two dimensions, you drop the \hat{k} term and write \vec{a} = a_1\hat{i} + a_2\hat{j}.

Resolving a 2D vector into componentsA vector a from the origin to a point in the first quadrant, with its projections onto the x and y axes shown as dashed lines forming a right-angled rectangle. x y θ a₁ = |a| cos θ a₂ = |a| sin θ a O
In 2D, the component along the $x$-axis is $|\vec{a}|\cos\theta$ and the component along the $y$-axis is $|\vec{a}|\sin\theta$, where $\theta$ is the angle the vector makes with the positive $x$-axis. The vector is the diagonal; its components are the two sides of the rectangle.

In two dimensions, if \vec{a} makes angle \theta with the positive x-axis, the components have a clean trigonometric form:

a_1 = |\vec{a}|\cos\theta, \qquad a_2 = |\vec{a}|\sin\theta

This is just right-triangle trigonometry. The vector is the hypotenuse, the x-component is the adjacent side, and the y-component is the opposite side.

Consider a concrete case. A force of 10 N acts at 60° to the horizontal. Its horizontal component is 10\cos 60° = 10 \times 1/2 = 5 N, and its vertical component is 10\sin 60° = 10 \times \sqrt{3}/2 = 5\sqrt{3} N. The single force has been split into two perpendicular forces. You can analyse the horizontal and vertical effects separately — which is exactly what you do in physics when resolving forces along and perpendicular to an inclined plane.

In three dimensions, the same idea applies but with three perpendicular projections. The vector \vec{a} has a shadow on each coordinate axis, and each shadow's length (with sign) is a component. The three shadows together reconstruct the original vector completely.

Magnitude from components

If you know the components, you can recover the magnitude using the Pythagorean theorem (extended to 3D):

|\vec{a}| = \sqrt{a_1^2 + a_2^2 + a_3^2}

In 2D, this reduces to |\vec{a}| = \sqrt{a_1^2 + a_2^2}.

This is the bridge between geometry and algebra: you convert vectors to components, do arithmetic with the components, and then convert back to a magnitude and direction when you need the geometric answer.

Why components make addition trivial

Suppose \vec{a} = a_1\hat{i} + a_2\hat{j} + a_3\hat{k} and \vec{b} = b_1\hat{i} + b_2\hat{j} + b_3\hat{k}. Then:

\vec{a} + \vec{b} = (a_1 + b_1)\hat{i} + (a_2 + b_2)\hat{j} + (a_3 + b_3)\hat{k}

You add the x-components, add the y-components, add the z-components. Three separate additions of ordinary numbers. The triangle law, the parallelogram law — all of that geometry is encoded in this simple rule. Components turn vector addition into something a calculator can do.

Similarly, scalar multiplication becomes:

k\vec{a} = ka_1\hat{i} + ka_2\hat{j} + ka_3\hat{k}

Multiply each component by the scalar. The geometry of stretching and reversing is now just multiplication of numbers.

Direction cosines and direction ratios

A vector's direction in 3D space is fully described by the three angles it makes with the coordinate axes. These angles, and the cosines of those angles, have standard names.

Direction cosines

Let \vec{a} = a_1\hat{i} + a_2\hat{j} + a_3\hat{k} make angles \alpha, \beta, \gamma with the positive x-, y-, z-axes respectively. The direction cosines of \vec{a} are:

\cos\alpha = \frac{a_1}{|\vec{a}|}, \qquad \cos\beta = \frac{a_2}{|\vec{a}|}, \qquad \cos\gamma = \frac{a_3}{|\vec{a}|}

They are often written as l, m, n:

l = \cos\alpha, \quad m = \cos\beta, \quad n = \cos\gamma

Each direction cosine is a component divided by the magnitude. This makes geometric sense: \cos\alpha measures how much of the vector's length is "spent" along the x-axis. If \alpha = 0, the vector lies entirely along the x-axis and \cos\alpha = 1. If \alpha = 90°, the vector is perpendicular to the x-axis and \cos\alpha = 0.

The fundamental identity

There is a constraint that direction cosines always satisfy. Since a_1 = |\vec{a}|l, a_2 = |\vec{a}|m, a_3 = |\vec{a}|n:

a_1^2 + a_2^2 + a_3^2 = |\vec{a}|^2(l^2 + m^2 + n^2)

But also a_1^2 + a_2^2 + a_3^2 = |\vec{a}|^2 (from the magnitude formula). Dividing both sides by |\vec{a}|^2:

l^2 + m^2 + n^2 = 1
\cos^2\alpha + \cos^2\beta + \cos^2\gamma = 1

This identity is not a coincidence — it says that the unit vector in the direction of \vec{a} lies on the unit sphere. The three direction cosines are the coordinates of a point on a sphere of radius 1, and every point on that sphere satisfies x^2 + y^2 + z^2 = 1.

This gives you a quick check: whenever you compute direction cosines, square them and add. If the sum is not 1, you have made an error.

Direction cosines as projections onto axesA 3D vector from the origin making angles alpha, beta, gamma with the three coordinate axes. The projections onto each axis are shown as dashed lines, labelled with the direction cosine formulas. x y z a α β a₁ = |a| cos α a₂ = |a| cos β
The angles $\alpha$ and $\beta$ that a vector $\vec{a}$ makes with the $x$- and $y$-axes. Each component is the magnitude times the cosine of the corresponding angle. The third angle $\gamma$ (with the $z$-axis, coming out of the page) is not shown but follows the same pattern.

Direction ratios

In practice, direction cosines involve square roots (because the magnitude is usually a square root). It is often easier to work with direction ratios, which are any three numbers proportional to the direction cosines.

If \vec{a} = a_1\hat{i} + a_2\hat{j} + a_3\hat{k}, then a_1 : a_2 : a_3 are direction ratios of \vec{a}.

Direction ratios are not unique. The vector 2\hat{i} + 3\hat{j} + 6\hat{k} has direction ratios 2 : 3 : 6, but also 4 : 6 : 12 (multiply each by 2), or 1 : 3/2 : 3 (divide each by 2). Any scalar multiple works. Direction cosines, by contrast, are unique (up to sign) — there is exactly one set of cosines that sums in squares to 1.

To convert direction ratios a : b : c to direction cosines, divide each by \sqrt{a^2 + b^2 + c^2}:

l = \frac{a}{\sqrt{a^2 + b^2 + c^2}}, \qquad m = \frac{b}{\sqrt{a^2 + b^2 + c^2}}, \qquad n = \frac{c}{\sqrt{a^2 + b^2 + c^2}}

Unit vector in a given direction

A unit vector is a vector with magnitude 1. Every nonzero vector has a unique unit vector pointing in the same direction, obtained by dividing the vector by its own magnitude:

\hat{a} = \frac{\vec{a}}{|\vec{a}|}

If \vec{a} = a_1\hat{i} + a_2\hat{j} + a_3\hat{k}, then:

\hat{a} = \frac{a_1}{|\vec{a}|}\hat{i} + \frac{a_2}{|\vec{a}|}\hat{j} + \frac{a_3}{|\vec{a}|}\hat{k}

The components of \hat{a} are exactly the direction cosines l, m, n. So a unit vector and its direction cosines carry the same information: the pure direction, with the magnitude stripped away.

This operation — dividing by the magnitude — is called normalisation. You are "normalising" the vector to have length 1 while keeping its direction. It is one of the most common operations in physics and computer graphics: whenever you care about direction but not magnitude, you normalise.

Normalisation: a vector and its unit vectorA long vector a of magnitude 5 is shown alongside its unit vector a-hat of magnitude 1, both pointing in the same direction. The unit vector is shorter but points identically. a (magnitude 5) â (magnitude 1) same direction, different length
Normalisation strips the magnitude while preserving the direction. The vector $\vec{a}$ of magnitude 5 becomes the unit vector $\hat{a}$ of magnitude 1 by dividing every component by 5.

Vector joining two points

If A = (x_1, y_1, z_1) and B = (x_2, y_2, z_2) are two points in space, the vector from A to B is:

\overrightarrow{AB} = (x_2 - x_1)\hat{i} + (y_2 - y_1)\hat{j} + (z_2 - z_1)\hat{k}

This is the difference of the position vectors: \overrightarrow{AB} = \vec{b} - \vec{a}, where \vec{a} and \vec{b} are the position vectors of A and B.

The magnitude of \overrightarrow{AB} is the distance between A and B:

|\overrightarrow{AB}| = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2 + (z_2 - z_1)^2}

This is the distance formula in 3D — the Pythagorean theorem applied twice. First in the xy-plane to get the horizontal distance, then once more incorporating the z-component. The vector framework gives you the distance formula, the direction of the line joining the two points, and the unit vector along that direction, all from one subtraction.

Direction of the line joining two points

The direction ratios of the line from A(x_1, y_1, z_1) to B(x_2, y_2, z_2) are simply (x_2 - x_1) : (y_2 - y_1) : (z_2 - z_1) — the components of \overrightarrow{AB}. The direction cosines are obtained by dividing each of these by the distance |\overrightarrow{AB}|.

Note that the direction from A to B is the opposite of the direction from B to A: the vector \overrightarrow{BA} = -\overrightarrow{AB}. The direction ratios change sign, but they still represent the same line (just traversed in the opposite direction). The direction cosines also change sign. If you only care about the line and not the direction of traversal, then direction ratios (a : b : c) and (-a : -b : -c) represent the same line.

Worked examples

Example 1: Direction cosines of a vector

Find the direction cosines and the unit vector of \vec{a} = 2\hat{i} - 3\hat{j} + 6\hat{k}.

Step 1. Compute the magnitude.

|\vec{a}| = \sqrt{2^2 + (-3)^2 + 6^2} = \sqrt{4 + 9 + 36} = \sqrt{49} = 7

Why: the magnitude is the 3D Pythagorean theorem. The clean answer 7 is a sign that the numbers were chosen kindly — 2, 3, 6 is one of the classic Pythagorean-like triples that give an integer magnitude in 3D.

Step 2. Compute the direction cosines.

l = \cos\alpha = \frac{2}{7}, \qquad m = \cos\beta = \frac{-3}{7}, \qquad n = \cos\gamma = \frac{6}{7}

Why: each direction cosine is the corresponding component divided by the magnitude. The negative sign on m means the vector points in the negative y-direction — its angle with the positive y-axis is obtuse.

Step 3. Verify the fundamental identity.

l^2 + m^2 + n^2 = \frac{4}{49} + \frac{9}{49} + \frac{36}{49} = \frac{49}{49} = 1 \quad \checkmark

Why: this is the mandatory check. If this sum were not 1, something would be wrong.

Step 4. Write the unit vector.

\hat{a} = \frac{2}{7}\hat{i} - \frac{3}{7}\hat{j} + \frac{6}{7}\hat{k}

Why: the unit vector is just the direction cosines assembled into component form. It has magnitude 1 and points in the same direction as \vec{a}.

Result: Direction cosines are \frac{2}{7}, -\frac{3}{7}, \frac{6}{7}. Unit vector is \hat{a} = \frac{2}{7}\hat{i} - \frac{3}{7}\hat{j} + \frac{6}{7}\hat{k}.

A projection of $\vec{a} = 2\hat{i} - 3\hat{j} + 6\hat{k}$ onto the $xz$-plane (ignoring the $y$-component). The $x$-component is 2 and the $z$-component is 6. The full vector in 3D has magnitude 7 — a fact hidden in this 2D slice but confirmed by the arithmetic.

The triple (2, 3, 6) appears frequently in Indian textbooks and competitive exams precisely because \sqrt{4+9+36} = 7 — an integer. Other clean triples to remember: (1, 2, 2) gives magnitude 3, and (3, 4, 0) gives magnitude 5 (the familiar Pythagorean triple).

Example 2: Vector joining two points

Find the vector from A(1, -2, 4) to B(4, 2, -2). Also find its magnitude, direction ratios, and the unit vector along \overrightarrow{AB}.

Step 1. Compute \overrightarrow{AB}.

\overrightarrow{AB} = (4-1)\hat{i} + (2-(-2))\hat{j} + (-2-4)\hat{k} = 3\hat{i} + 4\hat{j} - 6\hat{k}

Why: the vector from A to B is found by subtracting the coordinates of A from those of B, component by component. This is \vec{b} - \vec{a} in position vector language.

Step 2. Compute the magnitude.

|\overrightarrow{AB}| = \sqrt{3^2 + 4^2 + (-6)^2} = \sqrt{9 + 16 + 36} = \sqrt{61}

Why: \sqrt{61} does not simplify — 61 is prime. This is the distance between points A and B in 3D space.

Step 3. Read off the direction ratios and compute direction cosines.

Direction ratios: 3 : 4 : -6.

Direction cosines:

l = \frac{3}{\sqrt{61}}, \qquad m = \frac{4}{\sqrt{61}}, \qquad n = \frac{-6}{\sqrt{61}}

Why: direction ratios are just the components themselves. Direction cosines normalise them by dividing by the magnitude.

Step 4. Write the unit vector.

\hat{u} = \frac{3}{\sqrt{61}}\hat{i} + \frac{4}{\sqrt{61}}\hat{j} - \frac{6}{\sqrt{61}}\hat{k}

Result: \overrightarrow{AB} = 3\hat{i} + 4\hat{j} - 6\hat{k}, |\overrightarrow{AB}| = \sqrt{61}, direction ratios 3:4:-6, unit vector \frac{1}{\sqrt{61}}(3\hat{i} + 4\hat{j} - 6\hat{k}).

The $xy$-projection of the vector $\overrightarrow{AB}$. In this projection, the horizontal change is 3 and the vertical change is 4, giving a projected length of 5. The full 3D distance is larger ($\sqrt{61} \approx 7.81$) because the $z$-component adds $(-6)^2 = 36$ under the square root.

Notice the interplay between 2D and 3D: in the xy-plane alone, \overrightarrow{AB} looks like a 3-4-5 vector. But the z-component of -6 adds substantially to the total length, pushing the magnitude from 5 up to \sqrt{61} \approx 7.81. A 2D picture always underestimates a 3D distance.

Common confusions

Going deeper

If you came here to learn components, direction cosines, and the vector joining two points, you have it — you can stop here. What follows is for readers who want to see the deeper structure behind resolution.

Why three components are enough

In three-dimensional space, any vector can be written as a_1\hat{i} + a_2\hat{j} + a_3\hat{k}, and the decomposition is unique. This means \hat{i}, \hat{j}, \hat{k} form a basis for 3D space — a minimal set of vectors such that every vector can be expressed as a combination of them.

The key property is that \hat{i}, \hat{j}, \hat{k} are linearly independent: no one of them can be written as a combination of the other two. (You cannot build a z-direction vector from x- and y-direction vectors.) Any three linearly independent vectors in 3D space form a basis — not just the standard unit vectors. The standard unit vectors are simply the most convenient choice because they are mutually perpendicular and have unit length.

The number of vectors in a basis is the dimension of the space. A line is one-dimensional (one basis vector), a plane is two-dimensional, and our space is three-dimensional. This is why you need exactly three components — no more, no less — to specify a vector in 3D.

The angle between a vector and a coordinate plane

A vector makes angles with the coordinate axes, but it also makes an angle with each coordinate plane. The angle with the xy-plane, for instance, is 90° - \gamma (the complement of the angle with the z-axis). If the direction cosine with the z-axis is \cos\gamma = 6/7, then \gamma \approx 31.0° and the angle with the xy-plane is approximately 90° - 31° = 59°.

This complementary relationship is useful in physics. When you resolve a velocity into horizontal and vertical components, the angle you use is typically the angle with the horizontal plane, not with the vertical axis. The trigonometric functions swap: if the angle with the plane is \phi, then the component along the axis perpendicular to the plane is |\vec{a}|\sin\phi, not |\vec{a}|\cos\phi.

Projections and components are different concepts

The component of \vec{a} along \hat{i} is a number: a_1 = \vec{a} \cdot \hat{i} (using the dot product). The projection of \vec{a} onto the x-axis is a vector: a_1\hat{i}. The component is the scalar; the projection is the vector. In everyday usage, people often say "component" for both. But in formal work — especially when you study the dot product — the distinction matters.

The dot product formula \vec{a} \cdot \hat{i} = a_1 is a preview of a much more general idea: the component of \vec{a} along any direction \hat{u} is \vec{a} \cdot \hat{u}. The coordinate axes are not special — you can project onto any direction. Components along the standard axes are just the most common case.

Equal vectors in component form

Two vectors \vec{a} = a_1\hat{i} + a_2\hat{j} + a_3\hat{k} and \vec{b} = b_1\hat{i} + b_2\hat{j} + b_3\hat{k} are equal if and only if:

a_1 = b_1, \qquad a_2 = b_2, \qquad a_3 = b_3

One vector equation in 3D space is equivalent to three scalar equations. This fact is used constantly in problem-solving: when you set two vectors equal and extract three separate equations, you are using the uniqueness of the component decomposition. In competition mathematics, this technique — "equating components" — converts a single vector equation into a system of scalar equations that you can solve by standard methods.

The direction cosines of the coordinate axes

The direction cosines of the x-axis are \cos 0° = 1, \cos 90° = 0, \cos 90° = 0, i.e., (1, 0, 0). This is just \hat{i}. Similarly, the y-axis has direction cosines (0, 1, 0) = \hat{j}, and the z-axis has (0, 0, 1) = \hat{k}.

A vector that makes equal angles with all three axes has \cos\alpha = \cos\beta = \cos\gamma. By the fundamental identity:

3\cos^2\alpha = 1 \implies \cos\alpha = \pm\frac{1}{\sqrt{3}}

So the direction cosines are \left(\frac{1}{\sqrt{3}}, \frac{1}{\sqrt{3}}, \frac{1}{\sqrt{3}}\right) or its negative. This vector points along the main diagonal of a cube — the line from one corner of a cube to the diametrically opposite corner. The angle it makes with each axis is \arccos(1/\sqrt{3}) \approx 54.74°, which is not 45° (a common mistake). In two dimensions, the line y = x makes 45° with each axis. In three dimensions, the body diagonal of a cube makes a larger angle, because the "room" is shared among three axes instead of two.

Where this leads next