Question about "Rotation Matrix"
Hi, guys. I'm aware of the question about Mathematics is always so unpleasent.. but for many codes. I really don't know what do they mean? for example: there is a line of code below.
The line of code serves to get a direction of x-axis from the "Rotation Matrix".I know that every rows or every cols of "Rotation Matrix" stand for the elements associate with rotation. but I really don't know what is the meaning about these elements? and how to split into a row or a col? Could someone can tips a little for me? Much appreciation for you.
asked Mar 25 '17 at 04:52 AM in C++ Programming
A matrix is basically just a rectangular grid of numbers. As you probably know, we can describe points in space using three numbers: we pick one point in space that we call the origin and choose directions (and a unit) for left/right, up/down and back/forth. Since mathematicians like things short and difficult to understand they typically don't call these directions left/right, etc. but rather x, y and z coordinates. But no matter how we call them, if we write down these three numbers for x, y and z one after the other we know exactly about which point in space we are talking. For example, (0, 0, 0) is the origin that we chose, (1, 0, 0) is the point one unit to the right of the origin, etc. (Well, actually there is no real agreement whether the second number goes up/down or back/forth, that's why you hear about Y-up or Z-up coordinate systems.) And these three number are already an example of a matrix, although a very simple one that has just one row and three columns.
What we often want to do is move things around in space. So, for example if we take a line defined by the two points (0, 0, 0) and (1, 0, 0) and rotate it 90 degrees around the origin (or, more precisely, in the plane defined by the X and Y axis) we get the line from (0, 0, 0) to (0, 1, 0). That was easy, because 90 degrees is just a quarter of a full rotation and so the numbers work out all right. But what happens if we want to rotate the line by 20 degrees? If you are familiar with trigonometric functions such as sine and cosine you'll probably know that we can express the new coordinates in terms of the sine and cosine of this angle. If we rotate the point (a, b, 0) in the XY-plane around an angle X we get the resulting point (a cos(x) - b sin(x), a sin(x) + b cos(x), 0). In this example the third coordinate does not change because we are sneakily rotating in the plane defined by the X and Y axes, but of course, if you take some object and rotate it around you'll quickly notice that rotations can move points around in much more complex ways, and so we need more numbers to describe how a general rotation in space works. (However rotations always preserve the distance between points that are rotated and the angles between them. If we squash, stretch and bend stuff we are no longer rotating.)
Now, it's a bit hard to describe this without images, so I'll just glance over the rest really briefly, but it turns out that we can describe any rotation in space by 9 numbers. (Actually 9 numbers are way too much, but it's a format that's easy to understand and to compute with.) These numbers are typically written in 3 rows and 3 columns and this is what we call a rotation matrix:
One nice thing about matrices is that we can define operations like addition and multiplication for matrices and they provide us with useful results. For example if we first perform one rotation, then rotate the resulting points again, this can be described by simply multiplying the rotation matrices for the two rotations. Neat. However, there is no direct correspondence between the columns and rotations around a single axis, or rather there is but it's a bit messy. The Wikipedia article shows how the matrix corresponds to a rotation axis and angle and how it can be composed from rotations around the three main axes.
You can find much more information about this in a number of references. Some that I think might be helpful if you want to dive deeper into this topic are an Intuitive guide to Linear Algebra and this text about rotations.
Follow this question
Once you sign in you will be able to subscribe for any updates here