Vectors are enormously useful geometric object in maths and physics. Vectors express a direction and a magnitude (or length), often pictured as an arrow in 2D or 3D space.
Diagram 1. Euclidean vector
Vectors are key concept not only for producing geometry through code, but also for motion and interactive animation. One of the main uses of vectors are to express velocity, which is both speed and direction of travel.
Diagram 12. Euclidean vectorVelocity
The direction of a vector is can be simply represented with an arrow, with the length of the arrow expressing the magnitude. The information to create a 2D vector can be easily recorded with just two numbers, which can be negative or positive.
Diagram 23. Vector a Vector a = ( 3, 6 )
The key thing to remember is that vectors represent direction and magnitude without a location. For this reason vectors are often combined with a coordinate. Confusingly, 2D and 3D coordinates are generally ofter recorded in the same format as vectors, with just two or three numbers. However, coordinates are normally visually represented as points rather than arrows.
Diagram 34. Vector a, translated to point b (5,3)
There are a number of ways to manipulate and combine vectors with simple operations called vector maths.
...
a = ( 3, 6)
b = ( 7, 2)
a + b = (10, 5)
Diagram 45. Vector addition
Scaler Multiplication
Scaler Multiplication only effects the magnitude of the vector, leaving the direction unchanged. However, if the vector is multiplied by a negative, then the direction is reversed! Scaler Multiplication can be used to control the acceleration of space ship or to simulate wind resistance or drag. If an object in a game collides with wall for example, we could multiply the objects vector by -1, to reverse it's direction so that it bounces off the surface.
To do a Scaler Multiplication, simply multiply each component in the vector by the multiplication factor.
c = (4, 5)
2*c = (8, 10)
Diagram 56. Vector multiplication
Finding the magnitude
...