Skip to main content
CalcMax

Vector Projection Calculator

Result

3.0000

Scalar projection

x component of the projection
3.0000
y component of the projection
0.0000
z component of the projection
0.0000

A vector projection calculator works out how much of one vector lies along another, and reports the answer twice: as a signed scalar and as a vector. Type both as lists of numbers, such as 3 4 and 1 0, and the page gives the scalar projection first — the length of the shadow the first vector casts along the second, negative when they lean in opposite directions — followed by the projection vector itself, which is that same shadow written as a real vector lying on the second one. The scalar projection is the dot product divided by the length of the second vector; the projection vector takes that number and puts the direction back into it. Two or three components are accepted and both vectors must have the same count. Showing both outputs is the point of the page rather than a redundancy: the scalar projection measures along a line and therefore keeps a sign, while the projection vector only knows which line it is, so reversing the second vector flips the first output and leaves the second untouched. The second vector must not be the zero vector, since there is no direction to project onto; the first one may be, and its projection is then zero.

Vectors and their projections

Source vector uTarget vector vScalar projection of u onto vx component of the projectiony component of the projectionz component of the projection
3 41 03300
1 23 42.21.321.760
3 4-1 0-3300
1 00 10000
1 1 11 1 11.7321111
2 3 61 1 16.35093.66673.66673.6667
0 03 40000
1 2 22 2 12.66671.77781.77780.8889

Eight pairs, projected one way round, with the scalar first and then the three components of the vector it corresponds to. Rows one and three are a matched pair and the reason the table is worth reading: the source is 3 4 in both, the target is 1 0 in one and −1 0 in the other, and the scalar projection flips from 3 to −3 while the projection vector stays exactly (3, 0, 0) both times. Negating the target puts a minus sign in the numerator and another in the squared denominator, so the vector does not notice and the scalar does. Row two is the ordinary case with neither vector normalised, and the scalar comes out to a clean 2.2 while the components do not. Row four is the perpendicular pair: the scalar is 0 and the projection vector is the zero vector, which is a correct answer and the one place in the table where both outputs vanish together without either input being zero. Row five projects a vector onto itself, so the scalar is its own length, √3, and the components come back equal. Row six is three-dimensional with a target of equal components, giving three equal projection components. Row seven is the zero vector as the source, accepted with a projection of zero. Row eight is a three-dimensional pair with a negative component in the projection. There is no row with a zero target vector, deliberately: that case is refused, because the target supplies both the direction and the divisor. Every figure is recomputed when the page is built; the spaces in the first two columns are separators and not part of the numbers.

Formula

s = (u · v) ÷ |v| proj_v u = (s ÷ |v|) · v = ((u · v) ÷ |v|²) · v

Source vector u
The vector being projected — the one whose shadow is wanted. Two or three numbers separated by spaces or commas. It may be the zero vector, and its projection is then simply zero
Target vector v
The vector the shadow falls on, and the one that supplies the direction. This box and the other are not interchangeable: swapping them changes the answer, which is why they are labelled by role rather than numbered
u · v
The dot product of the two vectors: each pair of components multiplied and the products added. It appears in the numerator of both formulas, so it is worth noticing that a dot product of zero means the two vectors are perpendicular — which is the case that produces a projection of zero
|v|
The length of the target vector, which is what the dot product is divided by. If the target happens to have length 1 this division changes nothing, and the scalar projection is then just the dot product — the reference table's first row is that case, and it is the easiest row to check by hand
s
The scalar projection: how far along the target's direction the source reaches, as a signed number. It is negative when the two point in broadly opposite directions and zero when they are perpendicular. It is not the length of the source vector and it is not the dot product — it is the dot product divided by the target's length
proj_v u
The projection vector: the scalar projection multiplied by the unit vector of the target, which puts the direction back and gives a vector that lies exactly on the target's line. Its length is the absolute value of s
Sign of s
What reversing the target does. Negating the target vector flips the sign of the scalar projection, because the numerator changes sign and the squared length in the denominator does not — but the projection vector is unchanged, since the same negation appears once on top and once underneath
Zero target vector
Refused. The target supplies the direction and the divisor, and the zero vector has neither: the denominator would be zero, and there is no line to project onto. A zero source vector is a different matter and is accepted, giving a projection of zero
No unit
The scalar projection and the three components of the projection vector are all plain numbers here. The scalar projection has the same unit as the input components, since it is a length measured in them, but nothing on this page knows what that was
Four decimal places
How wide the outputs are written. The scalar projection is frequently a clean fraction of the inputs — 11 divided by 5 gives 2.2 exactly — while the vector components are almost always rounded

Use this page when you want the part of one vector that points along another, which is the step behind splitting anything into components. Taking the horizontal and vertical parts of a force is a projection onto the two axes; the work done by a force is the projection of the force onto the direction of travel, multiplied by the distance; a shadow, a component along a slope and the coefficient in a least-squares fit are all the same operation. The two outputs answer two different questions about it. The signed scalar answers how much, including which way: it is the one to use in further arithmetic, where a negative value means the source leans away from the target. The vector answers where, and it is the one to use when the answer has to be a vector — it lies exactly on the target's line, so it can be added to something else or drawn. Reversing the target vector is the fastest way to see the difference: the scalar changes sign and the vector does not, because the scalar is measured relative to an orientation and the vector is not. Perpendicular vectors give a projection of zero from both outputs, and zero is a real answer — it says the source has no component along the target at all. The one input that cannot be used is the zero target vector, since a direction and a divisor are exactly what it fails to provide.

Worked examples

  1. 3 4 onto 1 0

    1. Dot product: 3 × 1 + 4 × 0 = 3
    2. Length of the target: |1 0| = 1
    3. Scalar projection: 3 ÷ 1 = 3
    4. Projection vector: (3 ÷ 1) × (1, 0) = (3, 0, 0)

    The input the page loads with, and the case where nothing is hidden: the target is a unit vector, so dividing by its length changes nothing and the scalar projection is just the dot product. It is also the case that is easiest to check by eye, because the target lies along the x axis and the projection is the source with its y component dropped. That is what a projection does in the simplest possible setting — it keeps the part of the vector that points along the target and discards the rest.

  2. 1 2 onto 3 4

    1. Dot product: 1 × 3 + 2 × 4 = 11
    2. Length of the target: √(9 + 16) = 5
    3. Scalar projection: 11 ÷ 5 = 2.2
    4. Projection vector: (2.2 ÷ 5) × (3, 4) = (1.32, 1.76, 0)

    The ordinary case, where the target is not a unit vector and both divisions have to be done. The scalar projection comes out exact — 11 divided by 5 is 2.2 — while the vector components do not. Check that the answer really does lie on the target's line: 1.32 divided by 3 is 0.44, and 1.76 divided by 4 is 0.44, so the two components are in the same ratio as the target's, which is what being on that line means. The length of the projection is 2.2, the scalar, as it should be.

  3. 3 4 onto −1 0

    1. Dot product: 3 × (−1) + 4 × 0 = −3
    2. Length of the target: |−1 0| = 1
    3. Scalar projection: −3 ÷ 1 = −3
    4. Projection vector: (−3 ÷ 1) × (−1, 0) = (3, 0, 0)

    The same source and the same line as the first example, with the target pointing the other way, and the clearest demonstration on the page of what the two outputs each know. The scalar projection has flipped to −3: it is measured along an orientation, and the orientation has changed. The projection vector is bit for bit the one from the first example, (3, 0, 0), because negating the target introduces a minus sign in the numerator and another in the squared denominator, and the two cancel. The scalar knows which way the target points; the vector only knows its line.

  4. 1 0 onto 0 1

    1. Dot product: 1 × 0 + 0 × 1 = 0
    2. Length of the target: |0 1| = 1
    3. Scalar projection: 0 ÷ 1 = 0
    4. Projection vector: (0 ÷ 1) × (0, 1) = (0, 0, 0)

    Two perpendicular vectors, and the projection is zero in both outputs. This is a real answer and not a failure: it says the source has no part pointing along the target, which is exactly what perpendicular means. A dot product of zero is the signal to look for, and it is the only way to get a zero scalar projection without one of the vectors being zero. Both vectors are one unit long here, so neither is small — a zero projection between two full-length vectors is worth pausing over the first time it appears.

  5. 0 0 onto 3 4

    1. Dot product: 0 × 3 + 0 × 4 = 0
    2. Length of the target: √(9 + 16) = 5
    3. Scalar projection: 0 ÷ 5 = 0
    4. Projection vector: (0 ÷ 5) × (3, 4) = (0, 0, 0)

    The zero vector as the source: every product in the dot product is zero, so both outputs are zero without any division problem arising. Nothing on this page refuses this input. The refusal runs the other way — the target vector is the one that must not be zero, because it supplies the direction and the divisor, and a projection onto the zero vector has no line to land on.

Limitations

Both vectors must have the same number of components, and each must have two or three. The two boxes are not interchangeable and the labels say which is which: the source is the vector being projected and the target is the one it is projected onto. Swapping them produces a different answer that looks entirely reasonable, so if a result surprises you, check the two boxes before checking the arithmetic. The target vector must not be the zero vector, because it supplies both the direction and the divisor; the source vector may be zero, and its projection is then zero. Components are read as ordinary numbers: a comma followed by a space separates components, a comma with no space after it is read as a decimal point (1,5 is one and a half), and a thousands grouping is refused rather than guessed at — write 1500, not 1,500. Four decimal places is a display width rather than a claim of precision, and the projection vector is computed from the unrounded scalar, so reading a component back and dividing it by the corresponding target component may not reproduce the printed scalar exactly. The reference table shows the target and source vectors as typed and the four outputs, and it deliberately has no row for a zero target vector, which this page cannot compute. One overlap worth naming: the dot product appears in the projection formula as its numerator, and the unit vector appears in the second formula as the direction that gets multiplied back in — so this page leans on both of those tools without being either of them, and the projection is the quotient, not the dot product and not a normalised vector.

Frequently asked questions

What is the difference between the scalar projection and the projection vector?
The scalar projection is one signed number: how far along the target's direction the source reaches, negative when the two lean apart. The projection vector is that same distance written as a vector pointing along the target's line. The scalar knows which way the target points and the vector does not — reverse the target and the scalar flips sign while the projection vector is unchanged. Use the scalar in further arithmetic and the vector when the answer has to be a vector.
Why does the scalar projection come out negative?
Because the source vector leans away from the target rather than towards it. The scalar projection is measured along an orientation, so when the two vectors point in broadly opposite directions the answer is negative. It is not an error and it is not a sign convention that can be dropped: a force pulling backwards along a direction genuinely has a negative component along it, and work done can come out negative for the same reason.
Which vector is the one being projected?
The source vector, in the first box. The second box is the target vector, which supplies the direction the shadow falls along. The two are not interchangeable on this page: projecting u onto v and projecting v onto u are different numbers, and if you swap the two boxes the answer changes without anything looking broken. That is why the boxes are labelled by role instead of being called vector u and vector v.
What happens when the two vectors are perpendicular?
Both outputs are zero, and that is a real answer rather than a failure. A dot product of zero means the two vectors are perpendicular — it is the only way to get a zero scalar projection without one of the vectors itself being zero — and a zero projection says the source has no part pointing along the target at all. The reference table's fourth row is this case. Perpendicular forces do no work on each other, which is the same statement in physics.
Can the vector being projected be the zero vector?
Yes, and both outputs are zero: every product in the dot product is zero, and the division is by the target's length, which is fine. The refusal on this page runs the other way round. It is the target vector that must not be zero, because it supplies the direction and the divisor, and there is no line to project onto the zero vector.
What is the projection formula?
The scalar projection is the dot product of the two vectors divided by the length of the target: s = (u · v) ÷ |v|. The projection vector multiplies that scalar by the unit vector of the target, which is the same as the dot product times the target divided by the target's squared length. When the target already has length 1 both formulas simplify and the scalar projection is simply the dot product, which is why the reference table's first row is the one to check by hand.

References

Related calculators