2D Vector Calculator
Add, subtract, and compute dot product, cross product magnitude, unit vector, and angle between two 2D vectors.
Shows component-by-component working.
A vector has both magnitude (size) and direction, unlike a scalar which has only magnitude. Vectors are fundamental to physics, engineering, computer graphics, and machine learning.
Notation: A 2D vector is written as (x, y) or as a column matrix. A 3D vector is (x, y, z).
Basic vector operations:
Addition: (a, b) + (c, d) = (a+c, b+d) Example: (3, 2) + (1, 4) = (4, 6)
Subtraction: (a, b) − (c, d) = (a−c, b−d)
Scalar multiplication: k(a, b) = (ka, kb) Example: 3 × (2, −1) = (6, −3)
Magnitude (length): |v| = √(x² + y² + z²) Example: |(3, 4)| = √(9 + 16) = √25 = 5
Unit vector: v̂ = v / |v| (vector divided by its magnitude, giving length = 1) Example: (3, 4) / 5 = (0.6, 0.8)
Dot product: a·b = axbx + ayby + azbz Example: (2, 3) · (4, 1) = 8 + 3 = 11 Dot product = |a||b|cos(θ), so θ = arccos(a·b / (|a||b|))
Cross product (3D only): produces a vector perpendicular to both inputs (a × b)x = aybz − azby (a × b)y = azbx − axbz (a × b)z = axby − aybx
Worked example — finding angle between vectors: v1 = (1, 0), v2 = (1, 1) Dot product = 1, |v1| = 1, |v2| = √2 cos(θ) = 1 / √2 → θ = 45°
Applications:
- Physics: force, velocity, acceleration, electric fields
- Computer graphics: surface normals, lighting calculations, camera orientation
- Navigation: combining wind speed + aircraft speed to get ground speed
- Machine learning: word embeddings, similarity calculations