Vector Projection Calculator

Use this Vector Projection Calculator to enter values, adjust options, and review results in a compact responsive workspace.

Results are calculated automatically as you enter data.

Vectors

Vector A
Vector B

Formula and decomposition

A equals its projection on B plus the perpendicular rejection component.

Vector projection proj_B(A) -

Projection graph

▼ See explanations and tips below ▼

What Is Vector Projection?

Vector projection is a way to describe how much of one vector points in the direction of another vector. If Vector A represents the vector you want to break apart and Vector B represents the direction you care about, the projection of A onto B is the part of A that lies parallel to B.

This idea is useful because a vector often contains more than one directional effect. A force may point partly forward and partly upward. A velocity may point partly along a route and partly sideways. A data vector may have one part explained by a chosen direction and another part left over. Projection separates those parts cleanly.

The projection of A onto B is not the same as the projection of B onto A. The first vector is the one being decomposed. The second vector defines the direction or line onto which the first vector is projected.


Why Vector Projection Matters

Vector projection connects geometry with component arithmetic. Instead of relying only on a drawing, you can use dot products to find the exact parallel part of a vector.

This matters in many settings:

  • In math and linear algebra, projections are used for orthogonal decomposition, least-squares ideas, and distance-to-line or distance-to-subspace problems.
  • In physics and engineering, projections help find the part of a force, velocity, or displacement that acts in a chosen direction.
  • In computer graphics and robotics, projections help compare directions, constrain motion, and separate movement into useful components.
  • In analytic geometry, projections make it easier to understand angles, perpendicularity, and components along axes or custom directions.

Key Terms to Know

  • Vector: A quantity with components, such as \((4, 3)\) in 2D or \((2, -1, 3)\) in 3D.
  • Vector A: The vector being projected.
  • Vector B: The nonzero vector that defines the projection direction.
  • Dot product: A scalar found by multiplying matching components and adding the products.
  • Magnitude: The length of a vector.
  • Vector projection: The vector part of A that lies parallel to B.
  • Scalar projection: The signed amount of A in the direction of B.
  • Projection length: The nonnegative length of the projection vector.
  • Vector rejection: The part of A left after subtracting the projection; it is perpendicular to B.
  • Orthogonal decomposition: Writing a vector as the sum of a parallel part and a perpendicular part.

How Vector Projection Works

Projection starts with the dot product. For two 3D vectors

$$ A = (a_x, a_y, a_z) $$

and

$$ B = (b_x, b_y, b_z) $$

the dot product is

$$ A \cdot B = a_xb_x + a_yb_y + a_zb_z $$

In 2D, the same idea applies without the \(z\) components:

$$ A \cdot B = a_xb_x + a_yb_y $$

The magnitude of a vector is the square root of its dot product with itself:

$$ |B| = \sqrt{B \cdot B} $$

To project A onto B, scale B by the ratio of \(A \cdot B\) to \(B \cdot B\):

$$ \operatorname{proj}_B(A) = \frac{A \cdot B}{B \cdot B}B $$

Where:

  • \(A\) is the vector being projected.
  • \(B\) is the nonzero direction vector.
  • \(A \cdot B\) measures how strongly A points with or against B.
  • \(B \cdot B\) is the squared length of B.
  • \(\frac{A \cdot B}{B \cdot B}\) is the scale factor applied to B.

The scalar projection is the signed amount of A in B's direction:

$$ \operatorname{comp}_B(A) = \frac{A \cdot B}{|B|} $$

The rejection is the perpendicular remainder:

$$ \operatorname{rej}_B(A) = A - \operatorname{proj}_B(A) $$

Together, the projection and rejection decompose A into two perpendicular parts:

$$ A = \operatorname{proj}_B(A) + \operatorname{rej}_B(A) $$

The angle between nonzero A and nonzero B comes from the dot product formula:

$$ \cos(\theta) = \frac{A \cdot B}{|A||B|} $$

So the angle is

$$ \theta = \cos^{-1}\left(\frac{A \cdot B}{|A||B|}\right) $$

If A is the zero vector, it has no direction, so the angle between A and B is not meaningful even though the projection and rejection can still be computed. B must be nonzero because a projection direction cannot have zero length.


Examples of Vector Projection in Practice

Example 1: A Simple 2D Projection

Suppose

$$ A = (4, 3) $$

and

$$ B = (5, 0) $$

First compute the dot products:

$$ A \cdot B = 4(5) + 3(0) = 20 $$
$$ B \cdot B = 5(5) + 0(0) = 25 $$

Now find the scale factor:

$$ \frac{A \cdot B}{B \cdot B} = \frac{20}{25} = 0.8 $$

Multiply B by this scale factor:

$$ \operatorname{proj}_B(A) = 0.8(5, 0) = (4, 0) $$

The rejection is what remains after subtracting the projection from A:

$$ \operatorname{rej}_B(A) = (4, 3) - (4, 0) = (0, 3) $$

So A splits into a horizontal part and a vertical part:

$$ (4, 3) = (4, 0) + (0, 3) $$

The scalar projection is \(4\), and the projection length is also \(4\).


Example 2: A 3D Projection

Suppose

$$ A = (2, -1, 3) $$

and

$$ B = (4, 1, -2) $$

Compute the dot products:

$$ A \cdot B = 2(4) + (-1)(1) + 3(-2) = 1 $$
$$ B \cdot B = 4^2 + 1^2 + (-2)^2 = 21 $$

The scale factor is

$$ \frac{A \cdot B}{B \cdot B} = \frac{1}{21} $$

Therefore,

$$ \operatorname{proj}_B(A) = \frac{1}{21}(4, 1, -2) $$
$$ \operatorname{proj}_B(A) \approx (0.190476,\ 0.047619,\ -0.095238) $$

The rejection is

$$ \operatorname{rej}_B(A) = A - \operatorname{proj}_B(A) $$
$$ \operatorname{rej}_B(A) \approx (1.809524,\ -1.047619,\ 3.095238) $$

The scalar projection is

$$ \frac{1}{\sqrt{21}} \approx 0.218218 $$

This value is positive but small, so A has only a small component in the direction of B. The angle between the vectors is about \(86.6565^\circ\), which is close to a right angle.


Example 3: A Negative Scalar Projection

Suppose

$$ A = (-2, 1) $$

and

$$ B = (3, 0) $$

The dot product is

$$ A \cdot B = (-2)(3) + 1(0) = -6 $$

and

$$ B \cdot B = 3^2 + 0^2 = 9 $$

The projection is

$$ \operatorname{proj}_B(A) = \frac{-6}{9}(3, 0) = (-2, 0) $$

The scalar projection is

$$ \frac{-6}{3} = -2 $$

The negative sign means A points partly opposite the direction of B. The projection length is still nonnegative:

$$ |-2| = 2 $$

This is why the signed scalar projection and the projection length should not be treated as the same thing.


Example 4: Zero Vector A

Suppose

$$ A = (0, 0) $$

and

$$ B = (2, 3) $$

The projection of A onto B is

$$ \operatorname{proj}_B(A) = (0, 0) $$

and the rejection is also

$$ \operatorname{rej}_B(A) = (0, 0) $$

The angle between A and B is not defined because the zero vector has no direction. This is different from using the zero vector for B, which is not allowed at all because B defines the projection direction.


How to Interpret the Result

The projection vector is the part of A that runs along the direction of B. If the projection vector has the same general direction as B, the scalar projection is positive. If it points opposite B, the scalar projection is negative.

The scalar projection is signed:

  • A positive scalar projection means A points partly in the same direction as B.
  • A negative scalar projection means A points partly opposite the direction of B.
  • A zero scalar projection means A is perpendicular to B or A has no component in B's direction.

The projection length is nonnegative. It tells you how long the projection vector is, without preserving the sign.

The rejection vector is the part of A perpendicular to B. A long rejection means much of A lies away from the direction B defines. A rejection close to zero means A is nearly parallel or antiparallel to B.

The dot product helps explain the sign and size of the projection:

  • If \(A \cdot B > 0\), the angle between A and B is acute.
  • If \(A \cdot B = 0\), the vectors are orthogonal, as long as both are nonzero.
  • If \(A \cdot B < 0\), the angle between A and B is obtuse.

The angle is reported in degrees when A and B are both nonzero. If A is exactly zero, the angle is not meaningful. Every finite nonzero B, including a very small one, defines a valid direction.


Common Mistakes and Misconceptions

Using the zero vector for B. Vector B defines the direction of projection. A zero vector has no direction, so it cannot be used as the projection direction.

Reversing A and B. The projection of A onto B usually differs from the projection of B onto A. Always check which vector is being projected and which vector defines the direction.

Confusing scalar projection with projection length. The scalar projection is signed, while the projection length is nonnegative. A scalar projection of \(-2\) has projection length \(2\).

Forgetting the z-component in 3D mode. In 3D, the \(z\) components affect the dot product, projection, rejection, scalar projection, and angle. A 2D-looking graph cannot show the full 3D geometry.

Rounding too early. If you round the scale factor before multiplying by B, your projection and rejection may differ slightly from a calculator result. Keep full precision until the final step when possible.

Expecting physical unit conversion. Vector projection works on components. If the components represent meters, newtons, or another unit, all components should already be in consistent units before calculating. This calculator treats the entered components as unitless Cartesian components.

Assuming the projection is always between the tails of A and B. When the angle is obtuse, the projection points opposite the direction of B. This is normal and is shown by a negative scalar projection.


When to Use Vector Projection

Use vector projection when you need to find how much of one vector lies in a chosen direction.

Common use cases include:

  • Finding the component of a force along a ramp, cable, beam, or direction of motion.
  • Breaking a vector into parallel and perpendicular parts.
  • Measuring how far a vector is from a line or direction.
  • Checking whether two nonzero vectors are orthogonal.
  • Understanding the angle relationship between two vectors.
  • Preparing for topics such as orthogonal bases, least squares, and projections onto subspaces.
  • Comparing movement directions in graphics, navigation, robotics, or physics problems.

Limitations and Things to Keep in Mind

This calculation depends on the components you enter. If the components are wrong, incomplete, or in mixed units, the result will not represent the intended vector relationship.

The calculator supports 2D and 3D vectors. It does not handle complex-valued vectors, symbolic expressions, exact fraction output, or arbitrary-dimensional vectors.

Vector B must not be exactly zero. Every finite nonzero B, including a very small one, defines a direction. The calculator keeps dot-product and scale-factor diagnostics in mantissa/exponent form when ordinary decimal display would underflow or overflow.

A zero Vector A can still have a projection and rejection, but it does not have a meaningful direction, so the angle between A and B should not be interpreted.

Most numeric results are rounded for display. Very small nonzero values may appear in exponential notation, and rounded values may differ slightly from hand calculations that round intermediate steps.

In 3D mode, the numeric results include the \(z\) components. A graph preview may show only the x-y view, so use the numeric projection and rejection values for the full 3D result.

For coursework, engineering calculations, physics modeling, or other important decisions, double-check the input values, units, assumptions, and rounding. When the calculation affects safety, money, official records, or professional design work, consult a qualified professional or instructor.


How to Use This Calculator

  1. Choose 2D or 3D mode.
  2. Enter the x and y components of Vector A. In 3D mode, also enter the z component.
  3. Enter the x and y components of Vector B. In 3D mode, also enter the z component.
  4. Make sure Vector B is not the zero vector.
  5. Review the projection vector, scalar projection, projection length, rejection vector, rejection length, dot product, and angle.
  6. Use the formula steps to see the dot products, scale factor, projection multiplication, and decomposition.
  7. Use the graph to compare A, B, the projection, and the rejection. In 3D mode, remember that the graph preview may show only the x-y view even though the calculations include z.

Frequently Asked Questions

What is the formula for projecting A onto B?

The vector projection of A onto nonzero B is

$$ \operatorname{proj}_B(A) = \frac{A \cdot B}{B \cdot B}B $$

This formula scales B so that the result is the part of A that lies parallel to B.


What is the difference between vector projection and scalar projection?

Vector projection gives a vector, such as \((4, 0)\) or \((0.190476, 0.047619, -0.095238)\). Scalar projection gives a signed number that tells how much of A lies in B's direction. The scalar projection can be negative, but the projection length is nonnegative.


Why can't Vector B be zero?

Vector B defines the direction of projection. The zero vector has no direction, and the formula requires dividing by \(B \cdot B\), which equals zero when B is the zero vector.


What does a negative scalar projection mean?

A negative scalar projection means A points partly opposite the direction of B. The projection vector will lie on the same line as B but point in the opposite direction.


Is the rejection vector always perpendicular to B?

Yes, for an exact mathematical projection onto a nonzero vector, the rejection vector is perpendicular to B. Numerically, a displayed result may show tiny rounding differences, especially with decimal inputs or very small values.


Does 3D mode change the formula?

No. The same dot-product formula applies. In 3D, the calculation includes the x, y, and z components instead of only x and y.


What does the angle between vectors tell me?

The angle describes how closely the directions of A and B align. An angle near \(0^\circ\) means they point in nearly the same direction, an angle near \(90^\circ\) means they are nearly perpendicular, and an angle near \(180^\circ\) means they point in nearly opposite directions.


Sources and References

Books and Textbooks

  1. Gilbert Strang and Edwin “Jed” Herman. Calculus Volume 3. OpenStax, Rice University, 2016. Section 2.3, “The Dot Product,” and Chapter 2 key concepts on dot products, vector projections, scalar projections, angles, and work applications. https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product
  2. Dan Margalit and Joseph Rabinoff. Interactive Linear Algebra. Georgia Tech. Section 6.3, “Orthogonal Projection,” including orthogonal decomposition, closest-vector interpretation, and projection onto a line. https://textbooks.math.gatech.edu/ila/projections.html
  3. William Moebs, Samuel J. Ling, and Jeff Sanny. University Physics Volume 1. OpenStax, Rice University, 2016. Sections 2.2 and 2.4 on vector components, scalar products, dot products, and physical interpretations of projections. https://openstax.org/books/university-physics-volume-1/pages/2-2-coordinate-systems-and-components-of-a-vector and https://openstax.org/books/university-physics-volume-1/pages/2-4-products-of-vectors

Calculator-Specific Behavior

  1. Calculator interface and behavior details supplied for the Vector Projection Calculator, including supported dimensions, inputs, outputs, formatting, assumptions, limitations, and result interpretation notes.