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.
Inputs
Scalar Projection of a onto b
—
Explain my result
Get a plain-English breakdown of your result with practical next steps.
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 bˆ, 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