Vector Projection Calculator
Enter vectors A and B to find the projection of A onto B. The calculator returns the scalar projection (signed length), vector projection (the actual projected vector), the orthogonal component of A perpendicular to B, the dot product, both magnitudes, and the angle between the vectors. Choose 2D or 3D mode and see every step of the working.
Formula
Worked example
Project a = (2, -3, 5) onto b = (3, 6, -4). Dot product: 2*3 + (-3)*6 + 5*(-4) = 6 - 18 - 20 = -32. |b| = sqrt(9+36+16) = sqrt(61) ≈ 7.8102. Scalar projection = -32 / 7.8102 ≈ -4.0971. Projection factor c = -32 / 61 ≈ -0.5246. Vector projection = (-0.5246*3, -0.5246*6, -0.5246*(-4)) ≈ (-1.5738, -3.1475, 2.0984). Orthogonal component = (2-(-1.5738), -3-(-3.1475), 5-2.0984) = (3.5738, 0.1475, 2.9016).
What is vector projection?
The projection of vector A onto vector B is the component of A that lies exactly along the direction of B. Geometrically it is the shadow cast by A onto the line through B when light falls perpendicular to B. The result is itself a vector, pointing in the same direction as B (or opposite, if the angle between the vectors is obtuse). This is called the vector projection. The scalar projection is just the signed length of that shadow: it is positive when the angle between A and B is less than 90 degrees, zero when they are perpendicular, and negative when the angle is obtuse.
Formulas used by this calculator
For vectors A = (ax, ay) in 2D or A = (ax, ay, az) in 3D and similarly for B, the key formulas are: Dot product: A . B = ax*bx + ay*by [+ az*bz in 3D] Magnitudes: |A| = sqrt(ax^2 + ay^2 [+ az^2]), |B| = sqrt(bx^2 + by^2 [+ bz^2]) Scalar projection of A onto B: comp = (A . B) / |B| Vector projection of A onto B: proj = ((A . B) / |B|^2) * B Orthogonal component: orth = A - proj Angle between vectors: theta = arccos((A . B) / (|A| * |B|)) The orthogonal component is the part of A perpendicular to B. Together, proj and orth decompose A into two vectors that add back to exactly A.
Applications of vector projection
Physics uses projection constantly. The work done by a force F over a displacement d is the dot product F . d, which is |F| times the scalar projection of d onto F. The component of gravity acting along a slope is the projection of the gravitational force onto the slope direction. In computer graphics, lighting calculations use the dot product to find how much light hits a surface based on the angle between the surface normal and the light direction. In data science, Principal Component Analysis (PCA) projects high-dimensional data points onto lower-dimensional directions of maximum variance. Linear regression finds the projection of the target vector onto the column space of the input matrix. In navigation and robotics, projection is used to decompose velocity vectors into forward and lateral components.
Scalar projection vs vector projection
The scalar projection (also called the component of A along B) is a single number with a sign. It tells you how far along B the shadow of A falls, and whether it points in the same direction as B or the opposite. The vector projection takes that signed length and multiplies it by the unit vector of B, so you get back an actual vector pointing along B. If you only need a magnitude or a comparison, use the scalar projection. If you need to reconstruct the projection as a vector, or subtract it out to find the perpendicular part, use the vector projection. This calculator computes both, along with the orthogonal component, so you have everything needed for a full vector decomposition.
Projection types by angle between vectors
| Angle (degrees) | Scalar projection | Dot product | Meaning |
|---|---|---|---|
| 0 | Maximum positive = |A| | Positive | A and B point in the same direction |
| 0 to 90 | Positive | Positive | A has a component in the direction of B |
| 90 | 0 | Zero | A is perpendicular to B (orthogonal) |
| 90 to 180 | Negative | Negative | A has a component opposite to B |
| 180 | Maximum negative = -|A| | Negative | A and B point in opposite directions |
The angle between A and B determines the sign and size of the scalar projection.
Frequently asked questions
What is the difference between scalar projection and vector projection?
The scalar projection is a single signed number: the length of the shadow A casts onto B, positive if the angle is less than 90 degrees, negative if the angle is greater than 90 degrees. The vector projection is that length multiplied by the unit vector of B, giving you an actual vector that points along B. Use the scalar projection when you need a magnitude or sign, use the vector projection when you need a vector you can add or subtract.
What happens when the two vectors are perpendicular?
When A and B are perpendicular (orthogonal), their dot product is zero. This makes the scalar projection zero and the vector projection the zero vector. The orthogonal component equals A itself, because none of A lies along B.
Can the scalar projection be negative?
Yes. When the angle between A and B is greater than 90 degrees, the dot product is negative, so the scalar projection is negative. This means A points partly in the opposite direction to B. The projection vector then points in the direction opposite to B.
How do I verify the result by hand?
Compute the dot product A . B by multiplying corresponding components and summing. Divide by |B|^2 to get the projection factor c. Multiply c by each component of B to get the projection vector. Subtract the projection vector from A to get the orthogonal component. Check: the orthogonal component and projection vector should add back to exactly A.
Does it matter which vector I project onto which?
Yes - projection is not symmetric. The projection of A onto B and the projection of B onto A are generally different vectors of different lengths. The projection of A onto B lies along B, while the projection of B onto A lies along A. The scalar projections also differ unless |A| = |B|.
What is the orthogonal component used for?
The orthogonal component (rejection) is the part of A perpendicular to B. Together with the projection vector, it gives a complete decomposition: A = projection + orthogonal component. This decomposition is used in the Gram-Schmidt orthogonalization process, physics problems involving forces on inclined planes, and computer graphics calculations.