Learning and Applying Mathematics using Computing

Theory: Vectors

This post is a bit of theory about vectors, ready for more work on our bus scenario.

A lot of the recent posts on this blog (e.g. on drifting, braking) have involved manipulating X and Y speeds. In mathematics, these speeds are termed a two-dimensional vector, written as either (xSpeed, ySpeed), or like this:

\begin{pmatrix} \text{xSpeed} \\ \text{ySpeed} \end{pmatrix}

So if our current speed is 3 in the X direction and -4 in the Y direction, we can write this as (3, -4) or \begin{pmatrix} 3 \\ -4 \end{pmatrix}. We saw in the drifting post how to form X and Y speeds that move at a given speed and angle. This can be written in mathematical notation as:

\begin{pmatrix} \text{speed} \times \cos(\text{angle}) \\ \text{speed} \times \sin(\text{angle}) \end{pmatrix}

In fact, it’s so common that all parts of a vector get multiplied by the same number that mathematicians use a notation whereby the number is moved outside the vector — so this is the same as the above:

\text{speed} \times \begin{pmatrix} \cos(\text{angle}) \\ \sin(\text{angle}) \end{pmatrix}

A vector can represent anything where one element is X and one is Y, so it can be a position or a speed or an acceleration.

Adding and Splitting Vectors

Vectors can be added together, by independently adding their X components together and adding their Y components together. This is easily seen graphically, by joining one vector’s end point to the start point of the next, e.g.

The black vector is added to the red vector, which is equivalent to travelling along the black, then along the red. This adds up to the blue vector. The X component of the blue vector, 6, is the addition of the X component of the black vector (2) and of the red vector (4). Similarly, the Y component of the blue vector, 3, is the addition of the Y component of the black vector (5) and of the red vector (-2).

Just as you can add two vectors to make one, you can take one vector and subdivide it into two. The most helpful application of this is in splitting a vector into its X component and Y component:

This is quite trivial, but it turns out to often be useful to split the vector this way, as we will see in our next post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: