Vector Math Adding and Subtracting Vectors
You may have wondered, when we said that an array of numbers was called a 'vector', why we used that term. Isn't a vector just an arrow, or the line-based artwork that comes from programs like Illustrator or Flash?
Well, one way to represent an array of numbers is as a point on a grid. For instance, the vector [80,60] can be shown on a 2-dimensional grid:
More accurately, [80,60] describes the arrow, or vector, from (0,0) to (80,60), shown here in whitethat is, a vector which goes 80 units across and 60 down. For an array of 3 numbers, we'd of course draw a 3D vector:
So, why do we say that [80,60] represents the vector, and not the point it leads to? Well, in part because the point is meaningless when taken out of its context. One point is indistinguishable from any otherthey're all just dots (not even that, really).
A vector, on the other hand, includes its own context: it always specifies a direction and an amount. That's what it is. A vector that points 80 units across and 60 units down is notably different from one pointing 20 units across and 30 down. They are different vectors.
So, we can say that each array of numbers defines a vector. An array of numbers is a vector.
It may be obvious that you add two vectors simply by adding their component values:
[20,70] + [60, -10] = [80, 60]
This addition can be represented graphically, by placing the vectors end-to-end:
It follows that every vector can be broken down into a set of vectors representing its component values:
[80, 60] = [80,0] + [0, 60]
When you represent this addition graphically, you see that the components of 2D vectors make right triangles:
We'll use this later to apply to vectors certain properties of right triangles, such as the Pythagorean Theorem (which we discuss in the next section).
You subtract two vectors by subtracting their respective components:
[80, 60] - [20, 70] = [60, -10]
Subtracting a vector is the same as adding its inverse. That is:
-[c, d]= [-c,-d]
This is the same as following the vector in the reverse direction, e.g. instead of down and right, you travel up and left. You can represent this graphically simply by placing the arrowhead at the opposite end:
As you can see, we can find the vector between two layers simply by subtracting one's position from the other's. The distance between the two layers will be the length of this vector.
We discuss a couple of techniques for finding the length of a vector in the next section.
Entire contents © 2001 JJ Gifford.