Register to reply 
3x3 Identity and rotation matrices and how they work 
Share this thread: 
#1
Apr1913, 10:53 AM

P: 14

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 yrotation axes, but fails with the zaxis, 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 zaxis, 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. 


#2
Apr1913, 11:02 AM

P: 389

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] 


#3
Apr1913, 04:24 PM

P: 14

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 zaxis 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 zrotation matrix? I will look into axisangle if it is the only option to do what I'm looking for, but I'd like to understand this problem first. 


#4
Apr2013, 12:39 AM

P: 389

3x3 Identity and rotation matrices and how they work
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
Apr2013, 11:43 AM

P: 14

Ok, I'll try.
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 Zaxis, e.g. along the Xaxis, so that the Zaxis 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. 


#6
Apr2013, 01:46 PM

Emeritus
Sci Advisor
HW Helper
Thanks
PF Gold
P: 11,755

Think about it. If you're rotating about the zaxis, points on the zaxis 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
Apr2013, 02:56 PM

P: 14

I'm aware of that, check my first post. My question was about how to move the point away from the Zaxis; 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
Apr2013, 02:58 PM

Emeritus
Sci Advisor
HW Helper
Thanks
PF Gold
P: 11,755

You're not being very clear then. You're saying you're using a rotation about the zaxis that you know does not affect points on the zaxis, but you don't understand why those points don't move away from the zaxis. You must be leaving an important detail out.



#9
Apr2013, 03:31 PM

P: 14

Question: How is the identity matrix to be modified to give me a rotation around the Zaxis? If [itex]\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix}[/itex] yields no Zaxis 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
Apr2013, 03:46 PM

Emeritus
Sci Advisor
HW Helper
Thanks
PF Gold
P: 11,755

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 zaxis, then it's not going to affect points on the zaxis regardless of which vectors you use or how you arrange them. If you want a rotation that does move points off the zaxis, 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
Apr2013, 03:56 PM

P: 389

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
Apr2013, 05:54 PM

P: 14

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/counterclockwise rotation, can I? Thanks a lot for your patience guys. 


#13
Apr2013, 06:44 PM

P: 389

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] 


#14
Apr2113, 11:59 AM

P: 139

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
Apr2113, 01:42 PM

Emeritus
Sci Advisor
HW Helper
Thanks
PF Gold
P: 11,755

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 zaxis 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 xyplane by the angle θ. The zcoordinate is unaffected. Note that it's a rotation only in one plane, the xyplane. 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 xyplane. (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 xyplane. Similarly, (0, 1, 0) maps to (sin θ, cos θ, 0), which, again, is in the xyplane. You're not rotating about different axes with one matrix. 


#16
Apr2713, 03:52 PM

P: 14

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 premultiplication and rowmajor 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
Apr2913, 08:19 AM

Math
Emeritus
Sci Advisor
Thanks
PF Gold
P: 39,544

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 zaxis 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. 


Register to reply 
Related Discussions  
Powers of matrices equal to the identity matrix  Linear & Abstract Algebra  3  
Identity element for matrices  General Math  2  
2 nonsquare matrices whose product is the identity matrix?  Calculus & Beyond Homework  0  
Rotation Matrices  General Math  6  
Linear Algebra  Identity matrices  Calculus & Beyond Homework  2 