Skip to content
Math

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.

Your details

Switch between 2-component and 3-component vectors.
x-component of vector A.
y-component of vector A.
z-component of vector A (3D only).
x-component of vector B (the direction to project onto).
y-component of vector B.
z-component of vector B (3D only).
Scalar projection of A onto BObtuse angle
-4.0972

Signed length of the projection - negative when the angle is obtuse.

Projection vector - x-1.5738
Projection vector - y-3.1475
Projection vector - z2.0984
Orthogonal component - x3.5738
Orthogonal component - y0.1475
Orthogonal component - z2.9016
Dot product (A . B)-32
|A| (magnitude of A)6.1644
|B| (magnitude of B)7.8102
Angle between A and B131.66deg
Projection magnitude4.0972
Vectors orthogonal?No
Scalar projection-4.0972
Projection magnitude4.0972
|A|6.1644
|B|7.8102

Scalar projection: -4.0972, vector projection: (-1.5738, -3.1475, 2.0984)

  • The angle is 131.66 degrees (obtuse), so the scalar projection is negative - A points partly away from B.
  • The projection captures 66.5% of the length of A along the direction of B.
  • The projection vector and orthogonal component together reconstruct A exactly: proj + orth = A (in 3D).

Next stepIn physics, the scalar projection gives the component of a force, velocity, or displacement in a chosen direction. In data science it is the basis of PCA and linear regression projections.

Formula

projb(a)=abb2b,compb(a)=abb,θ=cos1 ⁣(abab)\operatorname{proj}_{\mathbf{b}}(\mathbf{a}) = \frac{\mathbf{a} \cdot \mathbf{b}}{|\mathbf{b}|^{2}}\,\mathbf{b}, \quad \operatorname{comp}_{\mathbf{b}}(\mathbf{a}) = \frac{\mathbf{a} \cdot \mathbf{b}}{|\mathbf{b}|}, \quad \theta = \cos^{-1}\!\left(\frac{\mathbf{a} \cdot \mathbf{b}}{|\mathbf{a}|\,|\mathbf{b}|}\right)

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 projectionDot productMeaning
0Maximum positive = |A|PositiveA and B point in the same direction
0 to 90PositivePositiveA has a component in the direction of B
900ZeroA is perpendicular to B (orthogonal)
90 to 180NegativeNegativeA has a component opposite to B
180Maximum negative = -|A|NegativeA 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.

Sources

Written by Dr. Rajiv Menon, PhD Applied Mathematician · Bengaluru, India

Applied mathematician bridging algebraic theory and computational tools for students, engineers, and everyday problem-solvers.

Search 3,500+ calculators

Loading search…