Friday, May 20, 2011

Programming a Robot

In physical situations, matrices arise when you want to work with and describe real world (multi-dimensional) objects. While there are other ways, using a matrix is often very convenient.

An example

Let's say you're programming a robot. You tell it that there is an obstacle five meters ahead, and two meters to the right. Now your robot then turns in place 't' degrees to the left. So, how do you calculate the location relative to the robot after the turn?

If you want to use matrices, you'd describe the original coordinates of the obstacle with the matrix

[[5]  [2]] = C 

and the rotation matrix:

[[cos(t) -sin(t)]  [sin(t)  cos(t)]] = R 

To get your new coordinates, preform the matrix multiplication: C' = R*C

and you're done! Your Robot will avoid the obstacle.

This is a very simple example, but if you write out the equations that you'd need you can see that as you scale dimensions, and the complexity of your operations, using matrices becomes more an more useful. (For example, you can multiply rotation matrices again and again to get the final rotation, and then apply that to all of your coordinates.)

I'm sure someone else can give a better example of using matrices, but this is mine.

1 comment: