Vectors are commonly used to represent the positions of points in a space, or also the displacement (direction and amount) between two points. In a 2D space, two values are needed to specify the position of a point. For example, a given point at distance x in the X direction and distance y in the Y direction is represented by:
Figure 1a shows point . For simplicity in text, the vector can also be represented as . The T turns (``transposes'') a vector from a horizontal direction to a vertical direction and vice versa: .
Figure 1: a) Point in 2D coordinate system. b) vector between points
and
If a vector is , then the length of that vector is:
The length of the vector is also called the norm of the vector, although more properly it should be called the norm or 2-norm, for reasons that we need not go into here.
Vectors can represent directions. In this case, the vector is usually a unit vector, that is, it has length 1. One can create a unit vector by dividing a vector by its length:
Vectors are added/subtracted by adding/subtracting their components:
Vectors can represent changes/differences in positions. In this case, the length of the vector is the distance between the points. If and are two point positions, then the vector between them (see Figure 1b) is:
and the distance between the points is the length of the vector between them.
The dot product between two vectors and is defined as:
The angle between two vectors is defined using the dot product: