linear algebra calculators

Vector Projection Calculator

Calculate the scalar projection of 2D vector A onto vector B. Use this when you need to find how much of vector A lies in the direction of vector B.

About this calculator

The scalar projection of vector A onto vector B measures the length of the shadow A casts along the direction of B. It is defined as: scalar projection = (A · B) / |B|, where A · B is the dot product and |B| is the magnitude of B. For 2D vectors, the dot product is A · B = ax·bx + ay·by, and the magnitude is |B| = √(bx² + by²). The result is a signed scalar: positive if A and B point in roughly the same direction, negative if they point in roughly opposite directions, and zero if they are perpendicular. This quantity is widely used in physics (e.g., resolving forces) and computer graphics (e.g., lighting calculations).

How to use

Suppose vector A = (3, 4) and vector B = (1, 2). First compute the dot product: A · B = (3)(1) + (4)(2) = 3 + 8 = 11. Next, find the magnitude of B: |B| = √(1² + 2²) = √(1 + 4) = √5 ≈ 2.236. The scalar projection = 11 / 2.236 ≈ 4.919. This means vector A extends approximately 4.919 units in the direction of vector B.

Frequently asked questions

What is the difference between scalar projection and vector projection?

The scalar projection of A onto B is a single number representing the signed length of A's shadow along B's direction, calculated as (A · B) / |B|. The vector projection, by contrast, is a vector pointing in the direction of B with that magnitude, computed as [(A · B) / |B|²] · B. This calculator returns the scalar projection. If you need the full vector projection, you would then multiply the scalar result by the unit vector of B.

Why can the scalar projection be a negative number?

The scalar projection is negative when the angle between vector A and vector B is greater than 90°. In this case, the dot product A · B becomes negative, making the entire result negative. Geometrically, this means A has a component pointing opposite to B's direction. This signed nature is useful in physics for determining whether a force aids or opposes a given direction of motion.

How is scalar projection used in real-world physics and engineering problems?

Scalar projection is fundamental to resolving forces along a given direction. For example, when analyzing how much of a pushing force contributes to motion along a slope, you project the force vector onto the slope's direction vector. In computer graphics, it is used in lighting models to determine how directly a surface faces a light source. In machine learning, it appears in algorithms like support vector machines where projections onto hyperplanes are computed.