3x3 Identity and rotation matrices and how they work

In summary, the conversation discusses the use of rotation matrices to rotate a point around the origin. The speakers mention an identity matrix and three rotation matrices, and the difficulties they are facing with rotating the point around the z-axis. They discuss the concept of vectors and how they are represented in a rotation matrix, as well as the role of the identity matrix in the rotation process. The conversation ends with a suggestion to try 2D rotations before attempting 3D rotations and an offer to provide source code for vector rotations.
  • #1
STENDEC
21
0
I'm trying to rotate a point about the origin [itex](0,0,0)[/itex] and starting with an identity matrix, this works fine for the x- and y-rotation axes, but fails with the z-axis, where the point just sits in place.

[itex]\begin{bmatrix}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
\end{bmatrix}
M_{ID}
\times
M_Z
\begin{bmatrix}
cos(\phi) & sin(\phi) & 0 \\
-sin(\phi) & cos(\phi) & 0 \\
0 & 0 & 1
\end{bmatrix}
[/itex]

I imagine the point is sitting on the z-axis, thus rotating around itself. I'm not sure how to modify the identity matrix to reposition it so that it rotates around the origin like with the other axes. I hope someone can point out to me what's needed here. Thanks.
 
Mathematics news on Phys.org
  • #2
The matrix you have there rotates a point around the z axis. Look at
http://en.wikipedia.org/wiki/Rotation_matrix
under "Basic rotations"
If you want to rotate around an arbitary axis you can use the equations under "Rotation matrix from axis and angle"
To understand how a rotation matrix works you should know that each column represents a 3D Vector which in turn represents one of the axis of the rotated coordinate system.
e.g.
[itex]\begin{bmatrix}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
\end{bmatrix}
[/itex]
consists of three Vectors
[itex]\left(\begin{array}{c}
1 \\
0 \\
0
\end{array}\right)
\left(\begin{array}{c}
0 \\
1 \\
0
\end{array}\right)
\left(\begin{array}{c}
0 \\
0 \\
1
\end{array}\right)
[/itex]
Lets call the 3 vectors [itex]\vec{xa}[/itex], [itex]\vec{ya}[/itex] and [itex]\vec{za}[/itex]
When you then have a coordinate [itex]\left(\begin{array}{c}
x \\
y \\
z
\end{array}\right)
[/itex] and you apply your matrix to it what you are basically doing is moving along the x, y and z axis of the rotated coordinate system, i.e. [itex]\vec{xa}*x + \vec{ya}*y + \vec{za}*z[/itex]
 
Last edited:
  • #3
I'm trying to understand what you're saying. If I rearranged the 1's an 0's in the ID matrix, couldn't I get a point(vector) that would respond to the z-axis rotation? By analogy with a roundabout, couldn't I move the vector from standing straight up to pointing outward, lying on the rotating disc?

I wrote a small program where i changed the identity matrix, but the point only changes its starting position - subsequent multiplications with the rotation matrix yet again do nothing. Surely it is not an inherent property of the z-rotation matrix?

I will look into axis-angle if it is the only option to do what I'm looking for, but I'd like to understand this problem first.
 
  • #4
Could you give an example? I have no idea what you mean.
To rotate a vector around the origin with a matrix you create the rotation matrix by one of the methods explained on the wikipedia site and then multiply the matrix with your vector.
 
  • #5
Ok, I'll try.

jGa3G6Q.jpg

This is what happens with the 3 rotation matrices multiplied by the identity matrix. X and Y rotate the point, Z just has it sitting there.

The way I understood your vector explanation, I thought I could somehow move the "point" (I want to rotate) away from the Z-axis, e.g. along the X-axis, so that the Z-axis can rotate it. I suspect I have some major misconception here, but i read a lot of articles and just don't get it.

I'm extracting the point location from the third column of the resulting matrix.
 
Last edited:
  • #6
Think about it. If you're rotating about the z-axis, points on the z-axis can't move. They're on the rotational axis.

For any rotation in 3D, there's going to be some axis along which points won't move. You need to specify exactly what kind of rotation you want.
 
  • #7
I'm aware of that, check my first post. My question was about how to move the point away from the Z-axis; that part doesn't seem to work as I expect it to. In above image, I would want a rotation that adds the third circle to the existing two.
 
  • #8
You're not being very clear then. You're saying you're using a rotation about the z-axis that you know does not affect points on the z-axis, but you don't understand why those points don't move away from the z-axis. You must be leaving an important detail out.
 
  • #9
  1. I have a 3x3 identity matrix.
  2. I have three rotation matrices as defined in online sources.
  3. I multiply the identity matrix with the rotation matrices (each separately).
  4. From the resulting matrix, I retrieve new point coordinates from the third column ([1][3], [2][3], [3][3] if you will).
  5. Optionally, I multiply the resulting matrix with the rotation matrix repeatedly, giving me a circle of points around that axis.
  6. This only works for X- and Y-axis rotation, the Z-axis matrix has no similar effect.

Question: How is the identity matrix to be modified to give me a rotation around the Z-axis?

If [itex]\begin{bmatrix}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
\end{bmatrix}[/itex] yields no Z-axis rotation, would something like e.g. [itex]\begin{bmatrix}
0 & 0 & -1 \\
0 & 1 & 0 \\
1 & 0 & 0
\end{bmatrix}[/itex] change that?

In my program it doesn't seem to.
 
  • #10
Sorry, it's still not clear what you mean. A rotation matrix maps a vector (x, y, z) to a vector (x', y', z').

I'm not sure what your intended role is for the identity matrix here. I'm guessing that you're taking each column to represent a vector. (Actually rows, not columns, since you're multiplying by the rotation matrix on the right.) By modifying the matrix, all you're doing is reordering or choosing slightly different vectors to be rotated.

If a rotation doesn't affect points on the z-axis, then it's not going to affect points on the z-axis regardless of which vectors you use or how you arrange them. If you want a rotation that does move points off the z-axis, you need to use a different rotation, not different vectors.

It would help if you gave specific examples of rotations about the x and z axes to illustrate your point.
 
  • #11
I also don't get why you use the identity matrix here? And why do you need 3 rotation matrices? No matter what the rotation axis is you only need one matrix.
Maybe you should first try a few 2D rotations using a matrix to understand it better before going 3D.
I could give you some Java source code for vector rotations with matrices if that would help.
 
  • #12
vela said:
I'm not sure what your intended role is for the identity matrix here. I'm guessing that you're taking each column to represent a vector. (Actually rows, not columns, since you're multiplying by the rotation matrix on the right.)
Yes, based on what DrZoidberg said, and on my positive results with X and Y rotations, I thought that somehow these triplets define a point's offset (or vector's magnitude). Replacing the 1's in the ID matrix with smaller/larger numbers, results in a corresponding offset change. When applying the rotation repeatedly, a smaller/larger circle of points results.

vela said:
If a rotation doesn't affect points on the z-axis, then it's not going to affect points on the z-axis regardless of which vectors you use or how you arrange them. If you want a rotation that does move points off the z-axis, you need to use a different rotation, not different vectors.
This is where my confusion stems from. I thought the matrix I start with prepares three points (vectors) by offsetting them from their respective axes.

vela said:
It would help if you gave specific examples of rotations about the x and z axes to illustrate your point.
Basically I want to draw three circles of points (with a certain radius) around the origin, one for each of the three spatial dimensions. This seemingly worked for two axes based on list items 1. and 2. in my post above, despite me not understanding the intrinsics. I understand that a vector can remain unaffected by one axis, but I don't understand how I can define said vector to be off this axis from the get go, so that it now points along e.g. the Y axis, thereby responding to X and Z rotations.

DrZoidberg said:
I also don't get why you use the identity matrix here? And why do you need 3 rotation matrices? No matter what the rotation axis is you only need one matrix.
So are you saying that I could start with a vector {x, y, z}, multiply that by a rotation matrix, take the resulting vector, multiply that by the rotation matrix, etc. to get the type of circle in my drawing? Would this also work just as well for a matrix that contains rotation around more than one axis?

I'm not sure I understand your second sentence. I do use one matrix per axis. I cannot tilt the rotation axis itself and just distinguish between clockwise/counter-clockwise rotation, can I?

Thanks a lot for your patience guys.
 
  • #13
STENDEC said:
Yes, based on what DrZoidberg said, and on my positive results with X and Y rotations, I thought that somehow these triplets define a point's offset (or vector's magnitude). Replacing the 1's in the ID matrix with smaller/larger numbers, results in a corresponding offset change. When applying the rotation repeatedly, a smaller/larger circle of points results.
By the way, in your original post the rotation matrix is incorrect. Compare it with the wikipedia article. The minus sign is at the wrong place. Furthermore in a matrix multiplication the order matters. The rotation matrix should be on the left and the vector/matrix you want to rotate on the right.


But if all you want to do is draw a circle in the plane of the x and y axes with [itex]\left(\begin{array}{c}
0 \\
0 \\
0
\end{array}\right)[/itex] as it's center you just ignore the z axis, i.e. z is always 0 and then you do a 2D rotation. Start with an angle of 0 and increase it in small steps until you reach an angle of [itex]2\pi[/itex]. At each step you calculate the point on the circle with [itex]r*\left(\begin{array}{c}
cos(\phi) \\
sin(\phi) \\
0
\end{array}\right)[/itex] where r is the radius of the circle.
Then you repeat the process for the other axes.
For a circle around the x-axis you do [itex]r*\left(\begin{array}{c}
0 \\
cos(\phi) \\
sin(\phi)
\end{array}\right)[/itex]
and for the y-axis [itex]r*\left(\begin{array}{c}
sin(\phi) \\
0 \\
cos(\phi)
\end{array}\right)[/itex]
 
Last edited:
  • #14
At the risk of too many cooks spoiling the soup, I'll try to help a little. It looks like you're trying to build up a general rotation matrix by combining three simpler rotations (rotating around the x, y, and z axes). That's the right idea, but the problem is that your rotation matrix in the first post only rotates around the z axis.

I think the confusion is arising because on the one hand you say you don't want this, but on the other hand you use notation like M_z which suggests some knowledge of what that matrix does. It should be clear from the third column of M_z that the vector (0,0,1) is not changed by it, so it does indeed rotate around the z axis. Look again at the "Basic Rotations" and "General Rotations" in the wikipedia article and make sure you understand what R_x, R_y, and R_z mean. Do you see why R_x rotates around the x axis? Look at the columns to see what happens to the basis vectors. (1,0,0) is unchanged, and the other two are rotated in the yz plane. Only when multiplying all three of those matrices together can you build up an arbitrary rotation. You haven't done that.

Lastly, I don't think your matrix is incorrect because it disagrees with wikipedia. It just means that it rotates vectors in the opposite direction as the article states, or it means that you can view it as rotating the axes to make a coordinate change. If you check the "Ambiguities" section or the talk page for that article, there is a ton of confusion because people can't agree on which interpretation is correct (they both are).
 
  • #15
The way you typically use a rotation matrix R is you multiply it by vector x to get a new vector x'. For example, take a rotation about the z-axis by the angle ##\theta##. The matrix that represents that rotation is given by
$$R = \begin{bmatrix}
\cos\theta & -\sin\theta & 0 \\
\sin\theta & \cos\theta & 0 \\
0 & 0 & 1
\end{bmatrix}.$$ If we apply it an arbitrary vector, ##\begin{bmatrix} x \\ y \\ z\end{bmatrix}##, we get
$$\begin{bmatrix} x' \\ y' \\ z'\end{bmatrix} =
\begin{bmatrix}
\cos\theta & -\sin\theta & 0 \\
\sin\theta & \cos\theta & 0 \\
0 & 0 & 1\end{bmatrix}
\begin{bmatrix} x \\ y \\ z \end{bmatrix} =
\begin{bmatrix} x\cos\theta - y\sin\theta \\ x\sin\theta + y\cos\theta \\ z \end{bmatrix}.$$ Note the multiplication by x is from the right. That's equivalent to the three equations
\begin{align*}
x' &= x\cos\theta - y \sin\theta \\
y' &= x\sin\theta + y\cos\theta \\
z' &= z
\end{align*} The first two equations you should recognize as a rotation in the xy-plane by the angle θ. The z-coordinate is unaffected.

Note that it's a rotation only in one plane, the xy-plane. I think you're misinterpreting your results with the identity matrix as a rotation in two different planes. What you actually calculated was the result of rotating the vectors (1, 0, 0), which is the first row of I, and (0, 1, 0), which is the second row of I, in the xy-plane. (It's rows, not columns, because you multiplied on the left.) In other words, you found the point (1, 0, 0) maps to the point (cos θ, sin θ, 0), which is in the xy-plane. Similarly, (0, 1, 0) maps to (-sin θ, cos θ, 0), which, again, is in the xy-plane. You're not rotating about different axes with one matrix.
 
  • #16
Thanks a lot guys, sorry I didn't respond earlier. I won't reply to each post individually, but note that they've been very helpful to me! In doing further reading I realized that I'm using pre-multiplication and row-major matrices; I would have avoided confusion if I had mentioned that from the start but wasn't aware of the ambiguity.

I was able to rotate a vector using the matrix from my fist post, and the way it works makes sense now. This also made me realize that I was essentially rotating three vectors in my first post. Treating the three rows of the 3x3 matrix as vectors, I now knew where to find the rotated coordinates (I had been looking in the wrong place).

I have further questions, but I think they go beyond the scope of the thread title, so if I can't figure them out myself I'll make a new thread. Thanks.
 
  • #17
You seem to be thinking that you can define a single "rotation" that will move every point in space except the origin. You can't. A rotation is necessarily a 'planar' operation and must have an axis of rotation. Every point is moved on a plane perpendicular to that axis and every point on the axis is not moved. One can, in fact, show that in any operation in three dimensional that does not change the distance between points must have a "fixed line"- a line of points that do not move.

You can rotate through angle [itex]\theta[/itex] around the x- axis using
[tex]\begin{bmatrix}1 & 0 & 0 \\ 0 & cos(\theta) & -sin(\theta) \\ 0 & sin(\theta) & cos(\theta) \end{bmatrix}[/tex]

around the y- axis using
[tex]\begin{bmatrix}cos(\theta)& 0 & -sin(\theta) \\0 & 1 & 0 \\sin(\theta) & 0 & cos(\theta) \end{bmatrix}[/tex]

and around the z-axis using
[tex]\begin{bmatrix}cos(\theta) & -sin(\theta) & 0 \\sin(\theta) & cos(\theta) & 0 \\ 0 & 0 & 1 \end{bmatrix}[/tex]

Rotations about other axes can be done by combinations of those but a rotation always has an axis.
 

1. What is a 3x3 identity matrix?

A 3x3 identity matrix is a matrix that has 1s along the main diagonal and 0s everywhere else. It is denoted by the symbol "I" and is a special type of square matrix that behaves like the number 1 in multiplication. When multiplied by any other matrix, the result is the same as the original matrix.

2. What is the purpose of a 3x3 identity matrix?

The main purpose of a 3x3 identity matrix is to act as a neutral element in matrix multiplication. It allows us to perform operations on matrices without changing their values. It also serves as a reference point for comparing other matrices.

3. How do rotation matrices work?

Rotation matrices are used to rotate points in a coordinate system. The matrix contains values that dictate the amount and direction of rotation. When multiplied by a vector, the resulting vector is rotated in the desired direction. The angle of rotation is determined by the values in the matrix.

4. What is the difference between a 3x3 identity matrix and a rotation matrix?

The main difference is that a 3x3 identity matrix does not change the values of the original matrix when multiplied, while a rotation matrix changes the orientation of points in a coordinate system. A 3x3 identity matrix only contains 1s and 0s, while a rotation matrix can have various values depending on the desired rotation.

5. Can a matrix be both a 3x3 identity matrix and a rotation matrix?

Yes, a matrix can be both a 3x3 identity matrix and a rotation matrix. This is possible when the values in the rotation matrix correspond to a rotation of 0 degrees, meaning there is no rotation. In this case, the matrix would only contain 1s along the main diagonal, making it an identity matrix as well.

Similar threads

Replies
2
Views
1K
  • Linear and Abstract Algebra
Replies
11
Views
4K
Replies
4
Views
1K
Replies
1
Views
1K
Replies
2
Views
386
  • Quantum Physics
Replies
1
Views
198
  • Advanced Physics Homework Help
Replies
1
Views
953
  • Quantum Physics
Replies
12
Views
1K
Replies
2
Views
1K
Back
Top