Vectors: Direction + Magnitude
A vector is a quantity that has both a size (magnitude) and a direction. Velocity, force, and displacement are all vectors — they tell you not just “how much” but also “which way.” A number alone (like temperature or mass) is a scalar. Vectors are the language of physics, engineering, and computer graphics.
What a Vector Looks Like
A vector in two dimensions can be described two ways:
- Magnitude and direction: “5 units at 30 degrees”
- Component form: (x, y) = (magnitude * cos(angle), magnitude * sin(angle))
We can visualize the vector by plotting the line from the origin to the point (mag * cos(angle), mag * sin(angle)):
The purple line shows the direction of the vector. The red horizontal line shows the y-component (how far up or down). The x-component is the horizontal distance from the origin to where the vector points.
Set the angle to 0 radians. The vector points purely to the right — it has an x-component equal to the magnitude and a y-component of 0. Now set the angle to pi/2 (about 1.57). The vector points straight up — all y-component, no x-component. The trig functions decompose the vector into horizontal and vertical parts.
Component Form
The most common way to work with vectors is in component form: v = (v_x, v_y).
Given magnitude |v| and angle theta:
- v_x = |v| cos(theta) (horizontal component)
- v_y = |v| sin(theta) (vertical component)
Going the other direction:
- |v| = sqrt(v_x^2 + v_y^2) (Pythagorean theorem)
- theta = arctan(v_y / v_x) (inverse tangent)
Vector Addition: The Parallelogram Rule
When you add two vectors, you place them tip-to-tail. The resultant vector goes from the start of the first to the end of the second. In components, it is beautifully simple:
(a_x, a_y) + (b_x, b_y) = (a_x + b_x, a_y + b_y)
The purple line is vector a, the red line is vector b, and the green line is the resultant (a + b). The resultant always falls between the two original vectors, like a compromise of their directions.
In physics, vector addition is how forces combine. If two people push a box in slightly different directions, the box moves along the resultant vector. This is why a boat crossing a river at an angle ends up somewhere downstream — its velocity and the river’s current add as vectors.
Scalar Multiplication
Multiplying a vector by a scalar k scales its magnitude by |k| and reverses its direction if k is negative:
k * (v_x, v_y) = (k * v_x, k * v_y)
- k > 1: The vector gets longer (stretched).
- 0 < k < 1: The vector gets shorter (compressed).
- k < 0: The vector flips direction and scales.
- k = 0: The zero vector — no magnitude, no direction.
The Dot Product
The dot product of two vectors produces a scalar:
a . b = a_x * b_x + a_y * b_y = |a| |b| cos(theta)
where theta is the angle between the vectors. The dot product tells you how much two vectors “agree” in direction.
- Dot product > 0: Vectors point in roughly the same direction (angle < 90 degrees).
- Dot product = 0: Vectors are perpendicular (angle = 90 degrees exactly).
- Dot product < 0: Vectors point in roughly opposite directions (angle > 90 degrees).
Set the angles so the two vectors are perpendicular (differ by about 1.57 radians). The yellow line showing cos(angle between) drops to zero. This is the geometric test for perpendicularity: two vectors are perpendicular if and only if their dot product is zero.
Unit Vectors
A unit vector has magnitude 1. To turn any vector into a unit vector, divide by its magnitude:
u = v / |v|
Unit vectors are useful because they capture only direction, with no magnitude information. The standard unit vectors are i = (1, 0) and j = (0, 1), so any vector (a, b) can be written as ai + bj.
Challenge: A plane is flying at 300 mph heading north (angle = pi/2). A crosswind blows east at 40 mph (angle = 0). Write both as vectors in component form, add them, and find the actual speed and direction of the plane. How many degrees off course is the plane blown?