2D vector calculator — dot product, angle, projection and more

Enter the x and y components of two vectors u and v, and the calculator gives their dot product, 2D cross product, lengths, sum, difference, the angle between them, the unit vector of u and the projection of u on v.

Live demo · real result from this tool
Dot product (u·v)0
Cross product (2D scalar, u×v)
-25
|u|
5
|v|
5
u + v
(7, 1)
u − v
(-1, 7)
Angle between
90°
Unit vector of u
(0.6, 0.8)
Projection of u on v
(0, 0)

Processed on your device — nothing is uploaded.

How to use the 2D vector calculator

  1. Enter vector u as u x and u y.
  2. Enter vector v as v x and v y.
  3. Read the Dot product (u·v) first. Below it are the Cross product (2D scalar, u×v), the lengths |u| and |v|, u + v and u − v.
  4. Read Angle between, Unit vector of u and Projection of u on v.

What it does and when to use it

Vectors describe anything with a size and a direction: a force, a velocity, a displacement on a map, or a direction in a game. The dot product and angle tell you how much two directions agree, which matters for work done by a force or lighting in graphics. The projection splits one vector into the part along another, such as the part of gravity acting down a slope. The cross-product sign tells a program whether to turn left or right.

For vectors with a z component, use the 3D vector calculator. The length |u| is the same calculation as the distance between two points from the origin. The trigonometry calculator helps when you start from a length and an angle.

How it works

For u = (u.x, u.y) and v = (v.x, v.y):

  • Dot product: u·v = u.x × v.x + u.y × v.y
  • 2D cross product: u×v = u.x × v.y − u.y × v.x
  • Magnitude: |u| = √(u.x² + u.y²)
  • Sum and difference: add or subtract matching components
  • Angle: θ = arccos(u·v ÷ (|u| × |v|))
  • Unit vector: u ÷ |u|
  • Projection of u on v: (u·v ÷ |v|²) × v

Worked examples

Angle between two vectors, step by step. u = (2, 3) and v = (5, −1).

  1. Dot product: 2 × 5 + 3 × (−1) = 10 − 3 = 7.
  2. Lengths: |u| = √(4 + 9) = √13 = 3.605551275 and |v| = √(25 + 1) = √26 = 5.099019514.
  3. cos θ = 7 ÷ (3.605551275 × 5.099019514) = 7 ÷ 18.38477631 = 0.3807498053.
  4. θ = arccos(0.3807498053).

The tool shows Angle between: 67.61986495° and Cross product (2D scalar, u×v): -17. The negative sign means v lies clockwise from u.

Splitting a vector. u = (6, 8) and v = (1, 0), a unit vector along the x-axis. The tool gives Projection of u on v: (6, 0), the horizontal part of u. The unit vector of u is (0.6, 0.8), and the angle is 53.13010235°.

Limits and tips

  • Only two components per vector. Points are not vectors: subtract start from end first if you have coordinates.
  • Results show up to 10 significant figures. Keep extra digits if you reuse a result in a later step.
  • There are no units; components can be in any unit, as long as both vectors use the same one.
  • Everything runs in your browser.

Frequently asked questions

What does the sign of the dot product mean?
Positive means the vectors point roughly the same way (angle under 90°), zero means they are perpendicular, and negative means they point more than 90° apart.
What is a 2D cross product?
In two dimensions the cross product is a single number, u.x × v.y − u.y × v.x. Its size is the area of the parallelogram the vectors make, and its sign shows whether v is anticlockwise (positive) or clockwise (negative) from u.
Is the angle between vectors always positive?
Yes. It is the smaller angle between them, from 0° to 180°. Use the sign of the cross product to tell which way round it goes.
What if one vector is (0, 0)?
A zero vector has no direction, so the angle shows as undefined. The unit vector of u and the projection on v are also undefined when that vector is zero.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close