Vector Projection
calculator.
Split a vector u into the part along a direction v and the part at right angles.
u is the vector you project; v gives the direction. Components can be fractions such as 1/2.
- Multiple of v
- 2
- Left over, length
- 2.2361
- Angle θ
- 14.0362°
The projection is 2 times v. The leftover part has length 2.2361, which is the distance from the tip of u to the line through v.
The shadow of u on the line through v
Drag a ringed tipu is ⟨7, 6⟩ and v is ⟨4, 2⟩. The projection ⟨8, 4⟩ lies on the line through v, and the dashed leftover part ⟨−1, 2⟩ meets that line at a right angle. Drag the ringed tips, or use the arrow keys on them, to change u and v.
Each part of u
Each part of u
| Vector | Components | Length |
|---|---|---|
| u | ⟨7, 6⟩Length 9.2195 | 9.2195 |
| v | ⟨4, 2⟩Length 4.4721 | 4.4721 |
| Projection onto v | ⟨8, 4⟩Length 8.9443 | 8.9443 |
| Left over, u − proj | ⟨−1, 2⟩Length 2.2361 | 2.2361 |
| Reflection of u | ⟨9, 2⟩Length 9.2195 | 9.2195 |
The reflection is the mirror image of u across the line through v: twice the projection, minus u.
Working
- 1Dot product of u and vu · v =7×4+6×2=40
- 2v with itself, the length of v squaredv · v =42+22=20
- 3Divide to get the multiple of vu · vv · v=4020=2
- 4Vector projection: that multiple of vprojv u =2⟨4,2⟩=⟨8,4⟩
- 5Scalar projection: the signed length along vu · v|v|=402√5=4√5≈ 8.9443
- 6What is left over at right anglesu − projv u =⟨−1,2⟩
- 7Check: the leftover part is at right angles to v(u − projv u) · v =0
How it's worked out
Shine a light straight down onto the line through v, and u casts a shadow on it. That shadow is the vector projection of u onto v. The projection formula multiplies v by one number: the dot product of u and v, divided by the dot product of v with itself.
The scalar projection is the signed length of that shadow. It divides the dot product by the length of v once, not twice, so it is a number rather than a vector.
Whatever is left after you take the shadow away points at right angles to v. Its dot product with v is always 0, which is the check the working ends with. Its length is the distance from the tip of u to the line through v.
The reflection of u across the line through v keeps the shadow and flips the leftover part to the other side, so it is twice the projection minus u.
Worked examples
Ravi finds the closest point on a straight path to a tree
A straight path leaves a gate in the direction ⟨4, 2⟩, measured in meters east and north. A tree stands at ⟨7, 6⟩ from the gate. Ravi wants the spot on the path nearest the tree, and how far off the path the tree is.
So the nearest point on the path is ⟨8, 4⟩. The leftover part is ⟨−1, 2⟩, and its dot product with the path direction is 0. Its length, √5 or about 2.24 m, is how far the tree is from the path. Along the path, that point is 4√5 or about 8.94 m from the gate.
The work a pull does when a crate moves
A rope pulls a crate with a force of ⟨10, 0, 5⟩ N, partly upward, while the crate slides along the floor by ⟨3, 4, 0⟩ m. Only the part of the force along the motion does work.
The scalar projection of the force onto the motion is 6 N. The crate moves 5 m, so the work is 6 × 5 = 30 J, which is the same as the dot product of force and motion.
The part of the force along the motion is the vector ⟨3.6, 4.8, 0⟩ N. The leftover part, ⟨6.4, −4.8, 5⟩ N, does no work on the crate as it slides.
A shadow that points the other way
Project ⟨−2, 1⟩ onto the x axis, given by ⟨1, 0⟩. The dot product is -2, so the projection is ⟨−2, −0⟩, pointing against v.
The scalar projection is −2. A negative value means the angle between the vectors is more than 90°, here 153.43°. The vector projection still lies on the line through v, just on the far side of the origin.
Reading your result
Only the direction of v matters. Projecting ⟨7, 6⟩ onto ⟨8, 4⟩ gives ⟨8, 4⟩, the same as onto ⟨4, 2⟩. Doubling v halves the multiple, 1 instead of 2, and the two changes cancel.
The multiple of v tells you where the shadow ends. A multiple between 0 and 1 means the shadow is shorter than v. Above 1 it reaches past the tip of v, and below 0 it points the other way.
Zero leftover means u is already on the line. For ⟨2, 4⟩ onto ⟨1, 2⟩ the leftover part is ⟨0, 0⟩, because ⟨2, 4⟩ is twice ⟨1, 2⟩. Zero projection means the opposite: u is at right angles to v.
The order matters. Projecting ⟨4, 2⟩ onto ⟨7, 6⟩ gives ⟨3.2941, 2.8235⟩, which lies along ⟨7, 6⟩ and has length 4.34, not 8.94.
Common mistakes
- Dividing by the length of v instead of its square. The vector projection divides by v · v. Dividing by |v| gives the scalar projection, and multiplying that by v stretches the answer by the length of v.
- Swapping u and v. "Project u onto v" lies along v. Typing the vectors the other way round gives a vector along u, with a different length.
- Dropping the sign of the scalar projection. A negative value is real information: the angle is over 90°. Writing its size alone loses which way the shadow points.
- Projecting onto the zero vector. It has no direction, so there is no line to project onto, and the tool says so instead of dividing by zero.