Welcome to Cartesian coordinate space! We’ll be spending a lot of time here, and because it’s so important to building, developing and programming robotic arms, we’ll need to get comfortable working with it to describe how things exist and move (specifically, chains of rigid bodies) within it.
First, a Disclaimer
There is nothing special about Cartesian space. It’s just a mathematical model to help us describe real space (i.e. the space that you are living in right now) in a more specific and workable way. There are lots of other kinds of mathematical spaces that are used to describe real-space, but Cartesian space is the easiest for our purposes here. It’s just a tool!
The Origin and the Axis’
In a Cartesian coordinate system, there two very important things to understand: The origin and the axis’.
The axis’ (pronounced “axe-ees”) are the three lines labeled X, Y and Z that you see in the image above. The z-axis is the line that runs up-down. The y-axis runs east-west, and the x-axis runs north-south.
The origin is the place in the image labeled O where these three axis’ intersect, which is right in the middle of the space.
Given these things, we can identify any point in space by just 3 numbers:
- How far up or down it is from the origin. This is called the z-coordinate
- How far east or west it is from the origin. This is called the y-coordinate
- How far north or south it is from the origin. This is called the x-coordinate
Vectors: How to Describe Points in Space
To make things nice and compact, we’ve developed a handy notation for describing these three coordinates in a Cartesian coordinate system, called vectors. A vector is just a one-dimensional array of these three coordinates, and looks like this:
The top number represents the x-coordinate, the second the y-coordinate, and the bottom number is the z-coordinate. In the case of the vector above, this point is 5 units past the origin on the x-axis, 7 units past the origin along the y-axis, and 9 units past the origin on the z-axis.
We call the position of a number in a vector the index to help identify which number in a vector we are talking about. The number at index 1 is the first number, the number at index 2 is the second number, and so on.
You can visualize the location of this (or any) point by using this simple technique:
- Imagine you are standing at the origin.
- Walk 5 units up the x-axis, then stop.
- Now walk 7 units up the y-axis, then stop again.
- Finally walk 9 units up the z-axis. You’re now at the point that the vector describes!
Again, a vector like this represents a point in our Cartesian space, and is usually visualized as an arrow or line:
In the image above, the a arrow represents a vector, where the ax line represents the x-coordinate for the vector (and similarly for ay and az).
Vectors are usually denoted by lowercase, bold letters like a or lowercase letters with an arrow on top .
Translation: Moving points from A to B
Let’s say that you have a vector a which describes a point in our Cartesian space, and you’d like move it a little bit up to describe a point that is 5 units higher on the z-axis. Changing a vector to describe a new point that is a fixed distance away in a particular direction is called translation.
It’s very easy to translate a vector, because it just requires us to add two vectors:
Adding two vectors is done horizontally: Add all the top numbers together to produce the resultant top number, add all the middle numbers to produce the resultant output number, etc.
Intuitively, you can imagine that you are standing at the point described by the first vector, and now the second vector begins at this point. If you follow that vector to it’s end, you’ll arrive at the sum. The image below illustrates this in the plane:
Similarly, you could move the same vector to describe a point that is 5 units lower on the z-axis by instead subtracting this displacement vector.
Matrices: How to Transform Vectors
So far, we’ve described the coordinate system, how we can represent points in space, and how we can add and subtract vectors to effectively translate them. But what if we want to do something more interesting with a point, like rotate it around the z-axis?
This is where matrices come in handy. In a Cartesian coordinate system, a matrix usually represents a transformation on a vector like:
- Rotating the vector around an axis
- Scaling it to be bigger or smaller
- Mirroring it across a plane
A matrix is just a two-dimensional array, and looks like this:
Usually capital letters are used to denote that a variable is a matrix
There is a special matrix called the Identity Matrix (Often denoted as I) that does absolutely nothing but spit out the original vector when applied to a vector. It is just a matrix that has all ones going down the center of the matrix diagonally, and zeroes elsewhere:
Using a Matrix to Transform a Vector
To transform a vector, we multiply the vector by the matrix to produce the transformed vector:
The dot in the equation above represents matrix multiplication. Matrix multiplication can be tricky at first, but with a little practice it becomes second nature. I won’t go into the details here, but this video by Khan Academy does a much better job of explaining it than I ever could. Watch it a few times and try it out yourself to really get the hang of it.
Matrix Inverses: The “Reverse” Transformation
Sometimes, we have a matrix that represents a certain transformation of a vector, but we would like to know what matrix we would need to “undo” that transformation. The answer, luckily, is simple: The inverse of the transformation matrix.
The inverse of a matrix is another matrix that, when multiplied by the original matrix, produces the identity matrix:
In this equation, A-1 represents the inverse of the matrix A. So for example, if A represented a rotation of 45 degrees around the z-axis, A-1 would represent a rotation of -45 degrees around the z-axis.
Applying Multiple Transformations to a Vector
Oftentimes, we want to apply several transformations to a vector in a particular order. Suppose we want to apply the transformation matrix A to a vector first, then apply the transformation matrix B to the result of this, and furthermore apply C to that result.
To do this, we multiply the vector by the three matrices:
Usually we omit the dot in-between the matrices and vectors, and the dot is then implied:
As you can see, to ensure that we multiply in the correct order, by arrange the matrices from right-to-left. So for the above equation, we would first multiply x by A, then multiple the result of that by B, and the result of that by C. In this way we have applied the A, B and C transformation matrices in the correct order.
And that it’s! You now know enough to be officially dangerous. There is certainly much more to be learned regarding vector spaces like this one, but for the purposes of learning about things like rigid body motion in space, this is enough for now.
Now that you’ve completed this lesson, be sure to check out our store for lots of cool robotic applications for your new knowledge!