Vectors and Vector Geometry
Vectors and Vector Geometry
Definition: A vector is a quantity with both magnitude and direction, typically written in component form (x, y), distinct from a scalar, which has magnitude only.
How It Works
- A scalar is a single number, like temperature or mass; a vector carries both a size and a direction, like velocity or force.
- In two dimensions, a vector is written as an ordered pair of components, v = (x, y), or drawn as an arrow from a starting point to an ending point.
- Vector addition can be done component-wise: (a, b) + (c, d) = (a+c, b+d). Geometrically, this is the tip-to-tail construction: place the second vector’s tail at the first vector’s tip, and the sum is the arrow from the very start to the very end.
- Scalar multiplication stretches or shrinks a vector without changing its direction (or reverses it, for a negative scalar): k(x, y) = (kx, ky).
- The magnitude (length) of a vector, written ‖v‖, is found with the Pythagorean theorem: ‖(x, y)‖ = √(x² + y²).
- A unit vector has magnitude exactly 1. Any nonzero vector can be turned into a unit vector pointing the same direction by dividing each component by the vector’s own magnitude.
- The dot product of two vectors, v·w = v_x·w_x + v_y·w_y, produces a single scalar, not another vector, which is why it’s also called the scalar product.
- The dot product connects directly to the angle between two vectors: v·w = ‖v‖‖w‖cos θ, which can be rearranged to solve for θ directly from the components alone.
- Two nonzero vectors are perpendicular (orthogonal) exactly when their dot product is zero, since cos 90° = 0. This is one of the most common practical uses of the dot product.
- Vectors generalize cleanly to three (or more) dimensions by simply adding more components, and most of the same rules (addition, magnitude, dot product) extend directly.
Illustration
var axIn = document.getElementById(‘vec-ax’), ayIn = document.getElementById(‘vec-ay’); var bxIn = document.getElementById(‘vec-bx’), byIn = document.getElementById(‘vec-by’); var axOut = document.getElementById(‘vec-ax-out’), ayOut = document.getElementById(‘vec-ay-out’); var bxOut = document.getElementById(‘vec-bx-out’), byOut = document.getElementById(‘vec-by-out’); var resetBtn = document.getElementById(‘vec-reset’);
function fmt(n) { return (Math.round(n * 100) / 100).toFixed(2).replace(/.00$/, ‘.0’); }
// Arrowhead as a small triangle: tip plus two points swept +-150 degrees // from the shaft’s own direction, at a short fixed radius. Verified by // hand for a vector pointing straight right and straight up in screen // coordinates before use, so it rotates correctly for every direction. function arrow(line, head, x1, y1, x2, y2) { line.setAttribute(‘x1’, x1); line.setAttribute(‘y1’, y1); line.setAttribute(‘x2’, x2); line.setAttribute(‘y2’, y2); var theta = Math.atan2(y2 - y1, x2 - x1); var r = 9; var a1 = theta + (150 * Math.PI / 180); var a2 = theta - (150 * Math.PI / 180); var p1x = x2 + r * Math.cos(a1), p1y = y2 + r * Math.sin(a1); var p2x = x2 + r * Math.cos(a2), p2y = y2 + r * Math.sin(a2); head.setAttribute(‘points’, x2 + ’,’ + y2 + ’ ’ + p1x + ’,’ + p1y + ’ ’ + p2x + ’,’ + p2y); }
function update() { var Ax = parseFloat(axIn.value), Ay = parseFloat(ayIn.value); var Bx = parseFloat(bxIn.value), By = parseFloat(byIn.value); axOut.textContent = fmt(Ax); ayOut.textContent = fmt(Ay); bxOut.textContent = fmt(Bx); byOut.textContent = fmt(By);
var origin = toPx(0, 0);
var aTip = toPx(Ax, Ay);
var bTip = toPx(Bx, By);
var rTip = toPx(Ax + Bx, Ay + By);
var ghostEnd = toPx(Ax + Bx, Ay + By);
var ghostStart = aTip;
arrow(aLine, aHead, origin[0], origin[1], aTip[0], aTip[1]);
arrow(bLine, bHead, origin[0], origin[1], bTip[0], bTip[1]);
arrow(rLine, rHead, origin[0], origin[1], rTip[0], rTip[1]);
bGhost.setAttribute('x1', ghostStart[0]); bGhost.setAttribute('y1', ghostStart[1]);
bGhost.setAttribute('x2', ghostEnd[0]); bGhost.setAttribute('y2', ghostEnd[1]);
var magA = Math.sqrt(Ax * Ax + Ay * Ay);
var magB = Math.sqrt(Bx * Bx + By * By);
var dot = Ax * Bx + Ay * By;
aTxt.textContent = 'A = (' + fmt(Ax) + ', ' + fmt(Ay) + ')';
bTxt.textContent = 'B = (' + fmt(Bx) + ', ' + fmt(By) + ')';
rTxt.textContent = 'A + B = (' + fmt(Ax + Bx) + ', ' + fmt(Ay + By) + ')';
magTxt.textContent = '|A| = ' + fmt(magA) + ', |B| = ' + fmt(magB);
dotTxt.textContent = 'A·B = ' + fmt(dot);
if (magA < 0.0001 || magB < 0.0001) {
angleTxt.textContent = 'Angle: undefined (a vector has zero length)';
} else {
var cosT = Math.max(-1, Math.min(1, dot / (magA * magB)));
var deg = Math.acos(cosT) * 180 / Math.PI;
var note = Math.abs(dot) < 0.05 ? ' (Perpendicular!)' : '';
angleTxt.textContent = 'Angle between A and B: ' + fmt(deg) + '°' + note;
}
}
[axIn, ayIn, bxIn, byIn].forEach(function (el) { el.addEventListener(‘input’, update); }); resetBtn.addEventListener(‘click’, function () { axIn.value = 5; ayIn.value = 2; bxIn.value = 2; byIn.value = 5; update(); });
update(); })();
Under the Hood
The key formulas, stated precisely:
Magnitude: |v| = sqrt(x^2 + y^2)
Dot product: v . w = v_x*w_x + v_y*w_y
Angle between vectors: cos(theta) = (v . w) / (|v| |w|)
Worked Example 1: Resultant of two vectors. Given: A = (3, 1), B = (-1, 4). Step 1: add component-wise: A + B = (3 + (-1), 1 + 4). Answer: A + B = (2, 5).
Worked Example 2: Dot product and the angle it implies. Given: A = (4, 0), B = (0, 3). Step 1: dot product = (4)(0) + (0)(3) = 0. Step 2: since the dot product is 0, cos θ = 0, so θ = 90°. Answer: A and B are perpendicular, confirmed directly by the dot product alone, no need to compute either magnitude.
Worked Example 3: Testing perpendicularity. Given: A = (2, 3), B = (6, -4). Step 1: dot product = (2)(6) + (3)(-4) = 12 - 12 = 0. Answer: A and B are perpendicular, even though neither vector is aligned with an axis.
History
- The geometric idea of adding displacements “tip to tail” is ancient, used implicitly in surveying and mechanics for centuries before any formal vector notation existed.
- Complex numbers, plotted on a plane by Caspar Wessel (1799) and Jean-Robert Argand (1806), provided an early two-dimensional number system that behaved much like modern vectors.
- William Rowan Hamilton introduced quaternions in 1843 while searching for a three-dimensional analogue to complex numbers, a more complicated system that included vector-like behavior as a special case.
- Josiah Willard Gibbs and Oliver Heaviside, working independently in the 1880s, stripped quaternions down into the simpler, purely vector-based notation (dot product, cross product) still used today.
- The transition was contentious. Many physicists initially preferred Hamilton’s quaternions, and it took roughly two decades of debate before Gibbs and Heaviside’s simpler vector notation became the accepted standard.
Why It Matters
- Physics describes force, velocity, and acceleration entirely as vectors, since direction is just as important as size for predicting motion.
- Computer graphics and game engines represent every position, movement, and camera direction as vectors, with the dot product used constantly for lighting calculations and visibility checks.
- GPS navigation computes displacement (how far and in what direction) as a vector difference between two coordinate points.
- Machine learning represents data as high-dimensional vectors, and measures similarity between them using a direct generalization of the 2D dot product.
- Structural engineers resolve forces acting on a beam or joint into vector components to check whether a structure is in balance.
Common Pitfalls
- Confusing a vector with a point. A point is a fixed location; a vector is a displacement, and the same vector can be drawn starting from anywhere.
- Forgetting that vector addition accounts for direction, not just size. Two vectors of length 5 can add up to anywhere between 0 and 10 in length, depending on their directions.
- Treating the dot product as if it always measures “how similar” two vectors are without regard to their magnitudes. A large dot product can come from large vectors that are only loosely aligned, not just from very well-aligned ones.
- Mixing up the dot product (a scalar) with the idea of “multiplying two vectors” in general, and expecting the result to be a vector.
Comparison
| Feature | Scalar | Vector |
|---|---|---|
| Carries direction? | No | Yes |
| Example | Temperature, mass, speed | Force, velocity, displacement |
| Combined by | Ordinary arithmetic | Component-wise addition (tip-to-tail) |
FAQ
What does a negative dot product mean? A negative dot product means the angle between the two vectors is greater than 90°, they point in generally opposing directions. A positive dot product means the angle is less than 90°; exactly zero means perpendicular.
Is the dot product the only way to “multiply” two vectors? No. In three dimensions there is also the cross product, which produces a new vector (perpendicular to both inputs) rather than a scalar. The dot product generalizes to any number of dimensions; the standard cross product is specific to three dimensions.
Example
A plane flying due east at 500 km/h in a 100 km/h crosswind blowing due north experiences a combined ground velocity that is the vector sum of the two, about 510 km/h at a slight angle off due east, found by exactly the tip-to-tail addition described above.
Related Terms
Referenced by