Vectors
© 1998, Particle

Inro

There are different types of variables, some like area, length, etc.. can be represented by one number, and then there are others, like acceleration, which need two variables. These other "variables" that need several numbers to represent are called "vectors".

Usually, a vector represents magnitude and direction. Vectors are usually represented by a directed line with an arrow.

A vector AB, consists of 2 points, point A and point B, the point A(the start) is called the initial point and point B the "end" is called the terminal point. The length (or magnitude) of a vector is denoted as |AB|. When the end points are not specified, vectors are denoted by boldface letters such as u, v, & w. The length of such vectors is denoted as |u|.

Two vectors are said to be quivalent, when both their length (or magnitude) and their direction is equivalent. Note that the beginning or ending points don't have to be the same for two vectors to be equivalent.

Calculating the length (or magnitude) of a vector is very simple. Lets think of vector PQ, with point P consisting of x1, y1 and point Q consisting of x2, y2, then the length (or magnitude) of such a vector is given by: (pseudo code follows)

|PQ| = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));

The direction can be found by examining the slope of the vector.

slope PQ = (y2-y1)/(x2-x1);

Note that finding the slope can sometimes be tricky, due to the possible divide by 0 error.

Vectors are usually represented by 2 numbers, these are numbers of the terminal point, the start of the vector is assumed to be the origin (a point at (0,0) ;-)

Because the exact points don't really matter, (2 vectors are equivalent if their magnitude and direction are equivalent), any vector (in 2D space) can be prepresented as 2 numbers. So, a vector v an just be prepresented by <a,b>. The magnitude can be prepresented as |v| = sqrt(a^2 + b^2);.

Vectors can be multiplied by scalars. Scalar multiplication is an operation in which a scalar is multiplied by a vector, to produce a vector. If the scalar is positive, then the vector's direction is not changed, only it's magnitude. If the scalar is negative, then the vector "reverses" direction. (and it's magnitude changes).

If s is the scalar, and v = <a,b> is the vector, then the resulting vector of s * v is <a*s,b*s>.

Vectors can also be added or subtracted. If we have 2 vectors u = <a,b> and v = <c,d>, then then resulting vector for addition is: <a+c,b+d>, and the resulting vector for subtraction is: <a-c,b-d>.

There are also special types of vectors, called unit vectors, they have the magnitude (or length) of 1. A regular vector v can be "converted" into a unit vector by multiplying it by a scalar value of 1/|v|.

There are 2 "special" vectors used in alternate vector notations... these 2 vectors are i = <1,0>, and j = <0,1>. Lets say we have a vector v = <a,b>, we can easily represent it as:

v = <a,b> = <a,0> + <0,b> = a<1,0> + b<0,1> = ai+bj

Using this notation, it's a little easier to figure out the direction angle of the vector... the direction where the vector is pointing. For a vector v = <a,b> we can write:

cos(ANGLE) = a/|v|
sin(ANGLE) = b/|v|

Reworking that, we can also write:

a = |v| * cos(ANGLE)
b = |v| * sin(ANGLE)

So, the whole vector now becomes:

v = (|v| * cos(ANGLE))i + (|v| * sin(ANGLE))j

This formula can be more useful than it seems... lets see what happens when we calculate the tan

tan(ANGLE) = sin(ANGLE)/cos(ANGLE) = (b/|v|)/(a/|v|) = b/a

With this little equation, we can quickly find the direction angle of a vector.

The Dot Product

...