Vectors: components, addition, dot and cross products
A vector has magnitude and direction. Split it into components and addition, scaling, dot and cross products all become simple arithmetic.
What is a vector?
Imagine you are giving someone directions. If you say 'walk 5 kilometres', they don't know where to go. If you say 'walk north', they don't know how far. A vector is a mathematical object that combines both: it has a magnitude (a length) and a direction (an angle). Force, velocity, acceleration and displacement are all vectors.
The three pillars of a vector
- Magnitude: The scalar size of the vector (e.g., speed, force intensity).
- Direction: The line along which the vector points (the angle).
- Orientation (Sense): Which way the arrow points along that line.
Breaking a vector into components
Computers and engineers don't usually work with 'angles' directly; they break vectors down into Components. By placing a vector on a Cartesian Plane, we can find its influence along the X and Y axes using Trigonometry.
Conversely, if we have the components, we use the Pythagorean Theorem to find the total magnitude and the Arctangent for the angle.
Adding and subtracting vectors
Adding vectors is not as simple as . If you walk 3m East and 4m North, you are 5m away from the start, not 7m. This is Vector Addition.
Visual Methods
- Tip-to-Tail Method: Place the start of the second vector at the end of the first. The result is the line from the very start to the very end.
- Parallelogram Method: Start both vectors from the same origin. Create a parallelogram; the diagonal is the resultant.
Scaling and normalising
Multiplication by a Scalar changes the length of a vector without changing its direction (unless the scalar is negative, which flips the direction 180°).
Normalization (Unit Vectors)
In game development and physics, we often only care about the direction. A Unit Vector is a vector with a magnitude of exactly 1. We create it through Normalization.
The dot product: measuring alignment
The Dot Product is one of the most powerful tools in physics. It takes two vectors and returns a single Scalar number. It measures how much one vector 'points' in the same direction as another.
| Angle (θ) | Dot Product Result | Meaning |
|---|---|---|
| 0° | Positive (Max) | Vectors point in the same direction. |
| 90° | Zero | Vectors are Orthogonal (Perpendicular). |
| 180° | Negative (Min) | Vectors point in opposite directions. |
The cross product: area and torque
Unlike the Dot Product, the Cross Product returns a Vector. In 3D, this vector is perpendicular to both inputs. In 2D, we calculate a 'Pseudoscalar' which represents the area of the parallelogram formed by the vectors.
This is crucial for calculating torque (rotational force) and for determining whether a point lies to the left or the right of a line — the sign of the 2D cross product tells you which side.
Frequently asked questions
What is the difference between a vector and a scalar?
Why isn't the magnitude of a sum equal to the sum of the magnitudes?
What does the dot product actually tell you?
When do I need to normalise a vector?
Keep exploring
- Add, subtract and dot vectors live in the Vector Operations simulation.
- Components in action — splitting a launch velocity: How projectile motion works.
- The unit circle behind and : Trigonometric Circle simulation.