terican

Last verified · v1.0

Calculator · math

Vector Projection Calculator

Calculate the scalar or vector projection of vector a onto vector b in 2D or 3D using the dot product formula.

FreeInstantNo signupOpen source

Inputs

Scalar Projection of a onto b

Explain my result

0/3 free

Get a plain-English breakdown of your result with practical next steps.

Scalar Projection of a onto b

The formula

How the
result is
computed.

What Is Vector Projection?

Vector projection describes the shadow one vector casts along the direction of another. Given two vectors a and b, the vector projection calculator computes either the scalar projection — a signed number measuring that shadow length — or the full vector projection, which is a vector pointing along b with the same signed length. Both quantities arise from a single operation: the dot product.

The Scalar Projection Formula

The scalar projection (also called the component of a along b) is defined as:

compb(a) = (a · b) / &lVert;b&rVert;

The variables are:

  • a · b — the dot product: axbx + ayby + azbz
  • &lVert;b&rVert; — the magnitude of vector b: √(bx² + by² + bz²)

A positive result means a has a component in the same direction as b; a negative result means the angle between them exceeds 90°. According to Paul's Online Math Notes — Dot Product, the scalar projection equals the length of the orthogonal projection of a onto the unit vector , making it the foundational building block for all projection computations.

The Vector Projection Formula

The vector projection extends the scalar result into a true vector:

projb(a) = ((a · b) / &lVert;b&rVert;²) · b

This vector points in the direction of b and has magnitude equal to the absolute value of the scalar projection. As explained in Georgia Tech Interactive Linear Algebra — Orthogonal Projection, projb(a) is the unique vector in the span of b such that a − projb(a) is orthogonal to b, a property that makes it indispensable in least-squares problems and Gram–Schmidt orthogonalization.

Step-by-Step Calculation

  • Step 1 — Dot product: Multiply matching components and sum: a · b = axbx + ayby + azbz.
  • Step 2 — Magnitude of b: &lVert;b&rVert; = √(bx² + by² + bz²).
  • Step 3 — Scalar projection: Divide the dot product by &lVert;b&rVert;. The result is compb(a).
  • Step 4 — Vector projection (optional): Multiply each component of b by (a · b) / &lVert;b&rVert;² to obtain the full projection vector.

Worked Example — 2D Vectors

Let a = (3, 4) and b = (1, 2). The dot product is (3)(1) + (4)(2) = 11. The magnitude of b is √(1 + 4) = √5 ≈ 2.236. The scalar projection is 11 / √5 ≈ 4.919. The vector projection is (11/5)(1, 2) = (2.2, 4.4). Notice that (2.2, 4.4) points in the same direction as b = (1, 2).

Worked Example — 3D Vectors

Let a = (2, 3, 1) and b = (1, 0, −1). The dot product is (2)(1) + (3)(0) + (1)(−1) = 1. The magnitude of b is √(1 + 0 + 1) = √2 ≈ 1.414. The scalar projection is 1 / √2 ≈ 0.707. The vector projection is (1/2)(1, 0, −1) = (0.5, 0, −0.5).

Geometric Interpretation

Vector projection has a clear geometric meaning. If you place the tail of vector a at the origin and the tail of b at the origin, then the projection vector projb(a) is the vector you obtain by "dropping a perpendicular" from the tip of a to the line spanned by b. The foot of that perpendicular lies on b's line, and the vector from the origin to that foot is exactly projb(a). This orthogonal decomposition is why projb(a) and (a − projb(a)) are perpendicular: the latter is precisely the perpendicular dropped from the projection. This decomposition arises throughout applied mathematics because it isolates the "aligned" part of a (parallel to b) from the "perpendicular" part, enabling least-squares fitting, Fourier analysis, and signal processing.

Real-World Applications

  • Physics — Mechanical work: The work done by a force equals the scalar projection of the force onto the displacement direction, multiplied by the displacement magnitude: W = F · d.
  • Computer graphics: Shadow rendering, Phong specular lighting, and camera view-space transforms all rely on projecting vectors onto surface normals or view directions.
  • Structural engineering: Decomposing a load into components parallel and perpendicular to a beam uses vector projection to determine axial vs. shear stress.
  • Machine learning — PCA: Principal Component Analysis projects high-dimensional data vectors onto eigenvectors (principal components) to reduce dimensionality while preserving maximum variance.
  • Aeronautics: Lift and drag are the projections of the total aerodynamic force onto the directions perpendicular and parallel to the free-stream velocity, respectively.

Reference

Frequently asked questions

What is the difference between scalar projection and vector projection?
The scalar projection (component) of a onto b is a single signed number: comp_b(a) = (a · b) / ||b||. It measures the signed length of the shadow a casts along b. The vector projection is a full vector pointing in the direction of b with that same signed length: proj_b(a) = ((a · b) / ||b||²) · b. For example, if the scalar projection of a onto b is 5 and b points along the x-axis, the vector projection is the vector (5, 0, 0).
How do you calculate vector projection in 3D?
Compute the dot product a · b = a_x·b_x + a_y·b_y + a_z·b_z. Then compute the squared magnitude of b: ||b||² = b_x² + b_y² + b_z². Divide the dot product by ||b||² to obtain the scalar coefficient, then multiply every component of b by that coefficient. For a = (2, 1, 3) and b = (1, 0, 1), the dot product is 2 + 0 + 3 = 5, ||b||² = 2, and the vector projection is (5/2)(1, 0, 1) = (2.5, 0, 2.5).
What does a negative scalar projection mean?
A negative scalar projection indicates that vector a has a component pointing in the direction opposite to vector b. Geometrically, the angle θ between the two vectors exceeds 90°, which makes cos θ negative and therefore makes the dot product a · b negative. For example, if a = (−4, 0) and b = (1, 0), the scalar projection is −4 / 1 = −4, meaning a points 4 units in the direction opposite to b.
When is the scalar projection equal to zero?
The scalar projection equals zero when vectors a and b are perpendicular (orthogonal). Perpendicular vectors have a dot product of exactly zero — no shared directional component — so the formula comp_b(a) = 0 / ||b|| = 0. A classic example: a = (0, 5) and b = (3, 0) are perpendicular because (0)(3) + (5)(0) = 0, so the scalar projection of a onto b is 0. This property is central to Gram–Schmidt orthogonalization in linear algebra.
How is vector projection used in physics and engineering?
Vector projection is essential to any problem requiring force or displacement decomposition. In physics, the work W done by force F over displacement d equals F · d, which is the scalar projection of F onto d multiplied by ||d||. In structural engineering, a diagonal load is projected onto the beam axis (axial component) and the perpendicular axis (shear component) to size fasteners and welds. In aerospace, lift and drag are projections of the net aerodynamic force onto axes normal and parallel to the velocity vector.
Can this vector projection calculator handle both 2D and 3D vectors?
Yes. For 2D vectors, enter the x and y components of each vector and leave the z fields set to 0. The zero z terms contribute nothing to the dot product or magnitude, so the calculator returns accurate 2D results automatically. For 3D vectors, fill in all six component fields. The formula comp_b(a) = (a · b) / ||b|| is identical in two and three dimensions; only the number of terms in the sum changes.