3D Vector Projection Calculator
Enter the components of two 3D vectors and this calculator projects one onto the other, showing the scalar projection, vector projection, perpendicular component, dot product, magnitudes, and the angle between the vectors.
Project One 3D Vector onto Another
3D Vector Projection Formula
Where:
- \(\mathbf{a} = (a_x, a_y, a_z)\) — the vector being projected
- \(\mathbf{b} = (b_x, b_y, b_z)\) — the vector that gives the direction
- \(\mathbf{a} \cdot \mathbf{b} = a_x b_x + a_y b_y + a_z b_z\) — the dot product
- \(\lvert \mathbf{b} \rvert = \sqrt{b_x^2 + b_y^2 + b_z^2}\) — the magnitude (length) of \(\mathbf{b}\)
The formula expresses how much of \(\mathbf{a}\) points in the direction of \(\mathbf{b}\). The fraction \(k = \frac{\mathbf{a} \cdot \mathbf{b}}{\lvert \mathbf{b} \rvert^2}\) scales \(\mathbf{b}\) so the result is the shadow \(\mathbf{a}\) casts onto the line through \(\mathbf{b}\).
Two related quantities come from the same projection:
\[ \operatorname{comp}_{\mathbf{b}} \mathbf{a} = \frac{\mathbf{a} \cdot \mathbf{b}}{\lvert \mathbf{b} \rvert} \qquad \operatorname{perp}_{\mathbf{b}} \mathbf{a} = \mathbf{a} - \operatorname{proj}_{\mathbf{b}} \mathbf{a} \]
The scalar projection (component) is the signed length of the shadow, and the perpendicular component (rejection) is the part of \(\mathbf{a}\) left over, which is always orthogonal to \(\mathbf{b}\).
3D Vector Projection – Calculation Example
Example: project \(\mathbf{a} = (2, 3, 1)\) onto \(\mathbf{b} = (1, 0, 2)\) (the calculator's default values).
\[ \mathbf{a} \cdot \mathbf{b} = 2 \cdot 1 + 3 \cdot 0 + 1 \cdot 2 = 4 \]
\[ \lvert \mathbf{a} \rvert = \sqrt{2^2 + 3^2 + 1^2} = \sqrt{14} \approx 3.742, \qquad \lvert \mathbf{b} \rvert = \sqrt{1^2 + 0^2 + 2^2} = \sqrt{5} \approx 2.236 \]
\[ k = \frac{\mathbf{a} \cdot \mathbf{b}}{\lvert \mathbf{b} \rvert^2} = \frac{4}{5} = 0.8 \]
\[ \operatorname{proj}_{\mathbf{b}} \mathbf{a} = 0.8 \cdot (1, 0, 2) = (0.8,\ 0,\ 1.6) \]
\[ \operatorname{perp}_{\mathbf{b}} \mathbf{a} = (2, 3, 1) - (0.8, 0, 1.6) = (1.2,\ 3,\ -0.6) \]
Result: the scalar projection is \(4 / \sqrt{5} \approx 1.789\), the vector projection is \((0.8, 0, 1.6)\), and the perpendicular component is \((1.2, 3, -0.6)\) with magnitude \(\approx 3.286\). The angle between the vectors is \(\arccos\!\left(\tfrac{4}{\sqrt{70}}\right) \approx 61.4°\).
How to Use the Calculator
- Enter the x-component (aₓ), y-component (aᵧ) and z-component (a_z) of the first vector under "Vector a — components".
- Enter the three components of the second vector under "Vector b — components". Use 0 for any missing axis.
- Choose the Project option: "a onto b" finds how much of \(\mathbf{a}\) lies along \(\mathbf{b}\); "b onto a" reverses the roles.
- Read the results: the scalar projection, the vector projection, the perpendicular component, plus the dot product, both magnitudes, the angle between the vectors, and a step-by-step breakdown of the calculation.
What Is a 3D Vector Projection?
Geometrically, the projection of vector \(\mathbf{a}\) onto vector \(\mathbf{b}\) is the shadow \(\mathbf{a}\) casts on the line through \(\mathbf{b}\), as if light shone perpendicular to that line. The result is a new vector that points in exactly the same (or exactly opposite) direction as \(\mathbf{b}\), with a length equal to how far \(\mathbf{a}\) extends in that direction. This is also called the vector component of \(\mathbf{a}\) along \(\mathbf{b}\).
Every projection splits a vector into two orthogonal parts: the projection itself (parallel to \(\mathbf{b}\)) and the perpendicular component, often called the rejection. The two parts always add back to the original vector: \(\mathbf{a} = \operatorname{proj}_{\mathbf{b}} \mathbf{a} + \operatorname{perp}_{\mathbf{b}} \mathbf{a}\), and their dot product is zero. This decomposition is the foundation of the Gram–Schmidt process, of resolving forces into components in physics, and of least-squares fitting in statistics.
The scalar projection answers the question "how far along \(\mathbf{b}\) does \(\mathbf{a}\) reach?" with a single signed number. It is positive when the angle between the vectors is less than 90°, zero when the vectors are perpendicular, and negative when the angle exceeds 90° — meaning \(\mathbf{a}\) points partly against \(\mathbf{b}\). The angle itself follows from the dot product via \(\cos\theta = \frac{\mathbf{a} \cdot \mathbf{b}}{\lvert\mathbf{a}\rvert\,\lvert\mathbf{b}\rvert}\), which is why the calculator reports it alongside the projection.
Note that the projection scales with the length of \(\mathbf{b}\) but not its direction: doubling \(\mathbf{b}\) halves the scale factor \(k\), so the vector projection itself is unchanged. In other words, the projection depends on the line through \(\mathbf{b}\), not on the specific vector — a direct-variation relationship between \(k\) and \(\lvert\mathbf{b}\rvert^{-2}\). You can explore such proportional relationships with the Direct Variation calculator.
Assumptions, Limitations and Tips
- Non-zero vectors required. The direction vector must have a positive magnitude, because the formula divides by \(\lvert\mathbf{b}\rvert^2\). A zero vector has no direction to project onto; the calculator will tell you which vector needs fixing.
- Sign matters. A negative scalar projection is a valid result: it means the projection points opposite to \(\mathbf{b}\), and the vector projection will contain negative multiples of \(\mathbf{b}\)'s components.
- Order matters. Projecting \(\mathbf{a}\) onto \(\mathbf{b}\) and \(\mathbf{b}\) onto \(\mathbf{a}\) generally give different vectors (only the scalar projections are related by \(\lvert\mathbf{a}\rvert\) and \(\lvert\mathbf{b}\rvert\)). Use the "Project" dropdown to switch directions.
- Perpendicular check. If the dot product is 0, the vectors are orthogonal: the projection is the zero vector and the perpendicular component equals the original vector.
- Magnitudes as RMS. The magnitude \(\lvert\mathbf{v}\rvert = \sqrt{v_x^2 + v_y^2 + v_z^2}\) is the root-mean-square of the three components multiplied by \(\sqrt{3}\); the same averaging idea appears in the Quadratic Mean (RMS) calculator.
- Parallel vectors. If the two vectors are parallel (angle 0° or 180°), the projection equals \(\mathbf{a}\) itself (up to sign), and the perpendicular component is the zero vector.
Frequently Asked Questions
How do I calculate a 3D vector projection by hand?
First compute the dot product \(a_x b_x + a_y b_y + a_z b_z\) and the squared length \(\lvert\mathbf{b}\rvert^2 = b_x^2 + b_y^2 + b_z^2\). Divide the dot product by \(\lvert\mathbf{b}\rvert^2\) to get the scale factor \(k\), then multiply each component of \(\mathbf{b}\) by \(k\). That product \(k\mathbf{b}\) is the vector projection. Subtract it from \(\mathbf{a}\) to get the perpendicular component.
What is the difference between scalar projection and vector projection?
The scalar projection is a single signed number: \((\mathbf{a}\cdot\mathbf{b})/\lvert\mathbf{b}\rvert\), the length of the shadow along \(\mathbf{b}\) (negative if the angle exceeds 90°). The vector projection is a full 3D vector \(k\mathbf{b}\) pointing along \(\mathbf{b}\) with exactly that length. They are related by \(\lvert\operatorname{proj}_{\mathbf{b}}\mathbf{a}\rvert = \lvert\operatorname{comp}_{\mathbf{b}}\mathbf{a}\rvert\).
Can a projection be negative or zero?
Yes. The vector projection is negative (a negative multiple of \(\mathbf{b}\)) when the angle between the vectors is greater than 90°, meaning \(\mathbf{a}\) points partly against \(\mathbf{b}\). It is the zero vector when the vectors are perpendicular, because then the dot product is 0. A negative result is valid — it is not an error, so don't discard the sign.
Why does projecting a onto b give a different answer than b onto a?
The two operations answer different questions. Projecting \(\mathbf{a}\) onto \(\mathbf{b}\) measures how far \(\mathbf{a}\) reaches along the line of \(\mathbf{b}\), and the result always lies along \(\mathbf{b}\). Swapping the roles gives a vector along \(\mathbf{a}\) instead. Only when the vectors are parallel (or one is a multiple of the other) do the two projections coincide, so always check which direction you selected.
What happens if the direction vector is the zero vector?
The formula divides by \(\lvert\mathbf{b}\rvert^2\), which is 0 for the zero vector, so the projection is undefined — a zero vector has no direction to project onto. The calculator detects this and asks you to enter a non-zero direction vector. The vector being projected may be anything, but both vectors need at least one non-zero component for the angle to be defined as well.
How is vector projection used in physics and other fields?
In physics it resolves forces and velocities into components along a given axis, e.g. splitting gravity into parts parallel and perpendicular to an inclined plane. In computer graphics it projects objects onto view directions, and in statistics the same mathematics underlies least-squares regression, where data is projected onto a model. The decomposition into parallel and perpendicular parts is also the key step in the Gram–Schmidt orthogonalization process.
Does the projection change if I scale the direction vector?
No. Multiplying \(\mathbf{b}\) by any non-zero constant leaves the vector projection unchanged, because the dot product and \(\lvert\mathbf{b}\rvert^2\) scale together and cancel out. Only the direction of \(\mathbf{b}\) matters, not its length. However, the scalar projection does change sign if you reverse \(\mathbf{b}\) (multiply by a negative constant), since it is signed relative to \(\mathbf{b}\)'s orientation.