Skip to main content
Home / Orthogonality / Projection Onto A Vector

Orthogonality

Orthogonal projections, bases, and distances

💡 Need Help?

  • • Enter fractions like 1/2
  • • Use decimals like 0.5
  • • Click "Load Example" to try a preset
  • • Click any step to copy LaTeX
Calculating...

Projection Onto A Vector Calculator

The projection of vector u onto vector v gives the component of u that lies in the direction of v. This is fundamental for understanding vector components, physics forces, and geometric relationships between vectors.

Dimension: D

Vector u (to project)

Vector v (direction to project onto)

Geometric Interpretation:

The projection of u onto v is the "shadow" of u when light shines perpendicular to v.

The result is a vector parallel to v (the projection) and a perpendicular component.

Enter fractions like 1/2 or decimals like 0.5. The projection formula: projvu = (u·v / ‖v‖²) v

What is Vector Projection?

Vector projection answers a fundamental question: "How much of vector u points in the direction of vector v?"

Definition: The projection of vector u onto vector v (denoted proj_v(u)) is the vector parallel to v that represents the "shadow" of u when light shines perpendicular to v.

🌞 Intuitive Example: Imagine the sun shining straight down. The shadow of a flagpole on the ground is the projection of the flagpole onto the ground.

  • Flagpole (u) = vector pointing up at an angle
  • Ground (v) = horizontal direction
  • Shadow (proj) = how much the flagpole extends horizontally

💡 Key Insight: Projection splits any vector into two parts: one that's parallel to v, and one that's perpendicular to v.


The Projection Formula

$$ \boxed{\text{proj}_{\mathbf{v}} \mathbf{u} = \frac{\mathbf{u} \cdot \mathbf{v}}{\|\mathbf{v}\|^2} \mathbf{v}} $$

Where:

  • u · v = dot product = u₁v₁ + u₂v₂ + ... + uₙvₙ
  • ‖v‖² = squared magnitude = v₁² + v₂² + ... + vₙ²
  • The fraction λ = (u·v)/(‖v‖²) is called the scalar projection coefficient

Scalar Projection (Component)

$$ \boxed{\text{comp}_{\mathbf{v}} \mathbf{u} = \frac{\mathbf{u} \cdot \mathbf{v}}{\|\mathbf{v}\|}} $$

The scalar projection gives the signed length of the projection vector. It's positive when u and v point in similar directions, negative when they point opposite.

For 2D Vectors

$$ \text{proj}_{\mathbf{v}} \mathbf{u} = \frac{u_1v_1 + u_2v_2}{v_1^2 + v_2^2} \begin{bmatrix} v_1 \\ v_2 \end{bmatrix} $$

For 3D Vectors

$$ \text{proj}_{\mathbf{v}} \mathbf{u} = \frac{u_1v_1 + u_2v_2 + u_3v_3}{v_1^2 + v_2^2 + v_3^2} \begin{bmatrix} v_1 \\ v_2 \\ v_3 \end{bmatrix} $$

Step-by-Step Calculation

How to Compute proj_v(u)

Step 1: Compute the dot product u·v

Step 2: Compute the squared magnitude ‖v‖²

Step 3: Calculate the scalar coefficient λ = (u·v) / ‖v‖²

Step 4: Multiply λ by v

Step 5: Find perpendicular component: u⟂ = u - proj_v(u)

Quick Formula for 2D:

$$ \text{proj}_{(a,b)}(x,y) = \frac{ax + by}{a^2 + b^2}(a,b) $$

Special Case: Unit Vector

If v is a unit vector (‖v‖ = 1), the formula simplifies dramatically:

$$ \text{proj}_{\mathbf{v}} \mathbf{u} = (\mathbf{u} \cdot \mathbf{v}) \mathbf{v} $$

Parallel and Perpendicular Components

Any vector u can be decomposed into two orthogonal components relative to v:

$$ \mathbf{u} = \mathbf{u}_{\parallel} + \mathbf{u}_{\perp} $$

📐 Parallel Component (u∥)

This is the projection itself:

$$ \mathbf{u}_{\parallel} = \text{proj}_{\mathbf{v}} \mathbf{u} = \frac{\mathbf{u} \cdot \mathbf{v}}{\|\mathbf{v}\|^2} \mathbf{v} $$

It points in the same direction as v (or opposite if λ is negative).

📐 Perpendicular Component (u⟂)

This is what's left over:

$$ \mathbf{u}_{\perp} = \mathbf{u} - \text{proj}_{\mathbf{v}} \mathbf{u} $$

It is orthogonal to v: u⟂ · v = 0

✨ Pythagorean Theorem for Vectors:

$$ \|\mathbf{u}\|^2 = \|\mathbf{u}_{\parallel}\|^2 + \|\mathbf{u}_{\perp}\|^2 $$

The squared length of u equals the sum of squared lengths of its components.


Complete Examples

Example 1: Projection in 2D

Vectors: u = (3, 4), v = (1, 0) (horizontal axis)

Step 1: Dot product u·v

$$ \mathbf{u} \cdot \mathbf{v} = (3)(1) + (4)(0) = 3 $$

Step 2: Squared magnitude ‖v‖²

$$ \|\mathbf{v}\|^2 = 1^2 + 0^2 = 1 $$

Step 3: Scalar coefficient

$$ \lambda = \frac{3}{1} = 3 $$

Step 4: Projection vector

$$ \text{proj}_{\mathbf{v}} \mathbf{u} = 3 \cdot (1, 0) = (3, 0) $$

Step 5: Perpendicular component

$$ \mathbf{u}_{\perp} = (3, 4) - (3, 0) = (0, 4) $$

Interpretation: The projection (3,0) is how far u extends horizontally. The perpendicular component (0,4) is entirely vertical. Check: (3,0)·(0,4) = 0 ✓

Example 2: Projection onto a Diagonal Vector

Vectors: u = (4, 2), v = (2, 1)

Step 1: Dot product u·v

$$ \mathbf{u} \cdot \mathbf{v} = (4)(2) + (2)(1) = 8 + 2 = 10 $$

Step 2: Squared magnitude ‖v‖²

$$ \|\mathbf{v}\|^2 = 2^2 + 1^2 = 4 + 1 = 5 $$

Step 3: Scalar coefficient

$$ \lambda = \frac{10}{5} = 2 $$

Step 4: Projection vector

$$ \text{proj}_{\mathbf{v}} \mathbf{u} = 2 \cdot (2, 1) = (4, 2) $$

Step 5: Perpendicular component

$$ \mathbf{u}_{\perp} = (4, 2) - (4, 2) = (0, 0) $$

Note: The projection equals u itself because u is already parallel to v (u = 2·v). The perpendicular component is zero.

Example 3: Projection onto Perpendicular Vector

Vectors: u = (3, 4), v = (0, 1) (vertical axis)

Dot product: u·v = (3)(0) + (4)(1) = 4

Squared magnitude: ‖v‖² = 0² + 1² = 1

Scalar coefficient: λ = 4/1 = 4

Projection: proj_v(u) = 4·(0,1) = (0,4)

Interpretation: The projection is the vertical component of u. The horizontal component (3,0) is perpendicular to v.

Example 4: 3D Projection

Vectors: u = (2, 3, 1), v = (1, 0, 0) (x-axis)

Dot product: u·v = (2)(1) + (3)(0) + (1)(0) = 2

Squared magnitude: ‖v‖² = 1² + 0² + 0² = 1

Scalar coefficient: λ = 2/1 = 2

Projection: proj_v(u) = 2·(1,0,0) = (2,0,0)

Result: The projection extracts the x-component of u. The perpendicular component is (0, 3, 1).


Special Cases

Case Condition Projection Result Perpendicular Result
u ∥ v (parallel) u = k·v proj = u u⟂ = 0
u ⟂ v (perpendicular) u·v = 0 proj = 0 u⟂ = u
v = 0 (zero vector) ‖v‖² = 0 Undefined N/A
u = 0 (zero vector) u = (0,0,...) proj = 0 u⟂ = 0
Unit vector v ‖v‖ = 1 (u·v) v u - (u·v)v

⚠️ Important: Projection onto the zero vector is undefined because you cannot divide by ‖v‖² = 0. Always use a non-zero direction vector.


Geometric Interpretation

In 2D Plane

  • proj_v(u) = shadow of u cast onto the line spanned by v
  • u∥ = component along the line
  • u⟂ = component perpendicular to the line
  • The projection is the closest point on the line to the tip of u

Think of v defining a line through the origin. The projection is where u "lands" on that line when you drop a perpendicular.

In 3D Space

  • v defines a line through the origin
  • Projection is the point on that line closest to u's tip
  • Distance from u to line = ‖u⟂‖
$$ \text{distance} = \|\mathbf{u} - \text{proj}_{\mathbf{v}} \mathbf{u}\| = \|\mathbf{u}_{\perp}\| $$

🔑 Key Geometric Fact: The projection is the orthogonal projection—the line connecting u to its projection is perpendicular to v.

$$ (\mathbf{u} - \text{proj}_{\mathbf{v}} \mathbf{u}) \cdot \mathbf{v} = 0 $$

Real-World Applications

⚙️ Physics: Forces on an Incline

When an object rests on an inclined plane, gravity decomposes into:

  • Parallel component: Pulls object down the slope (causes motion)
  • Perpendicular component: Presses object into the surface (causes friction)
$$ \mathbf{F}_{\parallel} = \text{proj}_{\text{slope}} \mathbf{F}_{\text{gravity}} $$

🏗️ Engineering: Stress Analysis

Forces on a surface are decomposed into:

  • Normal stress: Perpendicular to surface (pushing/pulling)
  • Shear stress: Parallel to surface (sliding)

📐 Computer Graphics

  • Shadows: Project points onto planes/lines
  • Reflections: reflect(u) = 2·proj_n(u) - u
  • Collision detection: Find closest point on line

📊 Machine Learning

  • Principal Component Analysis (PCA): Projects data onto principal components
  • Linear Regression: Projects data onto best-fit line
  • Feature extraction: Find components along important directions

🎮 Game Development

  • Camera projections: 3D to 2D screen projection
  • Movement along surfaces: Project velocity onto surface
  • AI pathfinding: Project positions onto paths

📈 Statistics: Linear Regression

The least squares regression line is the projection of the data vector onto the column space of the design matrix—a direct application of projection!


Frequently Asked Questions

Q: What's the difference between projection and component?

A: Vector projection (proj): A vector (has direction and magnitude)
Scalar projection (comp): Just a number (signed length)
Relationship: proj_v(u) = comp_v(u) · (v/‖v‖)

Q: Can I project onto a zero vector?

A: No! Projection onto the zero vector is undefined. Always use a non-zero direction vector.

Q: What if u and v are perpendicular?

A: Then proj_v(u) = 0. The projection is the zero vector, and u is entirely perpendicular.

Q: What if u and v are parallel?

A: Then proj_v(u) = u. The projection equals u itself, and the perpendicular component is zero.

Q: Can the scalar projection be negative?

A: Yes! When u and v point in opposite directions (angle > 90°), the dot product is negative, making λ negative. This means the projection points opposite to v.

Q: How is projection related to distance?

A: The shortest distance from the tip of u to the line spanned by v is exactly ‖u⟂‖ = ‖u - proj_v(u)‖.

Q: Does projection work in higher dimensions?

A: Yes! The formula works for any dimension (2D, 3D, 4D, etc.). The dot product generalizes naturally.


Practice Problems

Beginner

  1. Find proj_v(u) for u = (5, 0), v = (1, 0)
  2. Find proj_v(u) for u = (0, 4), v = (1, 0)
  3. Find the scalar projection of u = (3, 4) onto v = (1, 0)

Intermediate

  1. Compute proj_v(u) for u = (2, 5), v = (3, 1)
  2. Find the perpendicular component when projecting u = (4, 7) onto v = (2, 2)
  3. If proj_v(u) = (2, 4) and v = (1, 2), what is the scalar coefficient λ?

Advanced

  1. For u = (1, 2, 3) and v = (1, 1, 1), find both parallel and perpendicular components.
  2. Verify the Pythagorean theorem for vectors: ‖u‖² = ‖u∥‖² + ‖u⟂‖² using u = (3, 4) and v = (2, 1).
  3. If u = (a, b) and v = (1, 2), find a and b such that proj_v(u) = (2, 4).
Click to reveal solutions

1. proj = (5, 0) (u is already parallel to v)

2. proj = (0, 0) (u is perpendicular to v)

3. comp = 3

4. λ = (2·3 + 5·1)/(3²+1²) = (6+5)/10 = 11/10 = 1.1
proj = 1.1·(3,1) = (3.3, 1.1)

5. λ = (4·2 + 7·2)/(2²+2²) = (8+14)/8 = 22/8 = 2.75
proj = 2.75·(2,2) = (5.5, 5.5)
u⟂ = (4,7) - (5.5,5.5) = (-1.5, 1.5)

6. λ = 2 (since proj = λ·v → (2,4) = λ·(1,2) ⇒ λ=2)

7. λ = (1+2+3)/(1+1+1) = 6/3 = 2
proj = 2·(1,1,1) = (2,2,2)
u⟂ = (1,2,3) - (2,2,2) = (-1,0,1)

8. ‖u‖² = 9+16=25, ‖u∥‖²=‖(4.4,2.2)‖²=19.36+4.84=24.2, ‖u⟂‖²=‖(-1.4,1.8)‖²≈1.96+3.24=5.2, sum=29.4? Wait, recalculate carefully: u=(3,4), v=(2,1): λ=(6+4)/5=10/5=2, proj=(4,2), u⟂=(-1,2). Then ‖u‖²=25, ‖proj‖²=16+4=20, ‖u⟂‖²=1+4=5, sum=25 ✓

9. proj = λ·(1,2) = (λ, 2λ) = (2,4) ⇒ λ=2
λ = (a·1 + b·2)/(1²+2²) = (a+2b)/5 = 2 ⇒ a+2b=10
Any (a,b) satisfying a+2b=10 works, e.g., (10,0), (8,1), (6,2), etc.


Summary

🎯 Key Formulas to Remember

  • Vector Projection: proj_v(u) = (u·v)/(v·v) · v
  • Scalar Projection: comp_v(u) = (u·v)/‖v‖
  • Parallel Component: u∥ = proj_v(u)
  • Perpendicular Component: u⟂ = u - proj_v(u)
  • Orthogonality Check: u⟂ · v = 0
  • Pythagorean: ‖u‖² = ‖u∥‖² + ‖u⟂‖²

💡 Quick Check: The projection is always parallel to v, and the difference u - proj is always perpendicular to v.

Try It Yourself!

Use the calculator above to compute vector projections:

  1. Enter vector u (the vector being projected)
  2. Enter vector v (the direction vector)
  3. Click "Calculate" to see:
    • The projection vector proj_v(u)
    • The perpendicular component u⟂
    • The scalar projection coefficient λ
    • Verification that u = proj + u⟂
    • Visualization of the projection

📐 Try these examples:

  • 2D Example: u = (3, 4), v = (1, 0) → Project onto x-axis
  • 2D Diagonal: u = (4, 2), v = (2, 1) → Already parallel
  • Perpendicular: u = (3, 4), v = (0, 1) → Project onto y-axis
  • 3D Example: u = (2, 3, 4), v = (1, 0, 0) → Extract x-component

📐 Pro Tip: The scalar projection λ tells you "how much" of u points in the direction of v. If λ > 0, they point similarly; if λ < 0, they point oppositely.