# Rotation matrix sign convention confusion.

In rotation matrix, Why do we rotate the first and third rotation in the opposite direction of the 2nd rotation, this is confusing. Image is attached with this.

In this image we can note that for x and Z rotation non zero elements are same. But for Y rotation sign of sin(theta) changed.

why is so?

I think that the main issue is that you're trying to read your rotation matrices from left to right. The sign changes seem random, but actually cycle in an ordinary way. Below follows a more elaborate explanation with some more background information.

A) Why do minuses appear at all?

Followed by:

B) Why do minuses appear where they appear?

A)

From a mathematical point of view, it is not possible to construct a strictly positive rotation matrix. This can easily be deduced from the property that rotation matrices are skew-symmetric, i.e. $R=R^{-T}$. As such, it is not possible to define a rotation matrix without minuses or zeros appearing on non-diagonal elements. For example, it is not possible to define (a real number) $\theta$ (representing an angle) in any way to obtain the following matrix and call it a rotation matrix:

$$R\neq\left[\begin{matrix}\cos{\theta} & \sin{\theta} \\ \sin{\theta} & \cos{\theta} \end{matrix}\right]$$

(This matrix is 2D but the same applies to 3D)

A more intuitive explanation is that all three axes of the Cartesian coordinate system are defined to be orthogonal to each other, i.e. at 90 degrees. If mapping a horizontal coordinate component from Y to X requires a rotation of 90 degrees, it follows that mapping from X to Y (i.e. the cross-diagonal element on the rotation matrix) requires a rotation of -90 degrees. The difference between the two is 180 degrees, i.e. a change of sign.

B)

So, minus has to appear somewhere, but why are they appearing as they do? For instance, in a 2D X-Y coordinate system where X is pointing right and Y is pointing up, we could define rotation $\theta$ to be counter-clockwise (cc), or clockwise (c) leading to either of the following two rotation matrices respectively:

$$R_{cc}=\left[\begin{matrix}\cos{\theta} & -\sin{\theta} \\ \sin{\theta} & \cos{\theta} \end{matrix}\right]$$

$$R_{c}=\left[\begin{matrix}\cos{\theta} & \sin{\theta} \\ -\sin{\theta} & \cos{\theta} \end{matrix}\right]$$

As you may already know, we have (nearly) globally accepted to use the former. It is just a convention, defining axes to point to the right and up and the rotation to be counter-clockwise.

Now, let's move to 3D. We cannot simply speak of clockwise and counter-clockwise and right and up anymore, because we are not forced to observe the image from a specific direction. To fix this minor issue, we rewrite our conventions such that they are also applicable in 3D:

1) We use right-handed Cartesian coordinated systems:

2) We use right-handed rotations:

Now, if you look straight at the X-Y coordinate system along Z, we obtain the same coordinate system we had in 2D (Y pointing up, X pointing right). We find that Z is pointing towards you. Due to Z pointing towards you, the rotation will be counter-clockwise and we use the rotation matrix $R_{cc}$.

We can do the same for the Y-Z coordinate system (Z pointing up, Y pointing right), along X. Now X will be pointing towards you. Again, we use $R_{cc}$.

Next, we have the Z-X coordinate system (X pointing up, Z pointing right), along Y. We find exactly the same, i.e. Y pointing towards you. However, Z-X does not appear as obvious in the rotation matrix, because our (flat) matrix has finite width and height rather than being circular.

If you read your rotation matrix from left to right, what appears is the X-Z coordinate system instead of the Z-X coordinate system, also along Y, but now we see that Y is pointing away from you now. This changes the direction of rotation. Hence, you see $R_c$ appearing instead of $R_{cc}$.

Analysing X-Y, Y-Z and Z-X makes more sense than X-Y, Y-Z and X-Z. Try to read your rotation matrix in a more cyclic way, rather than from left to right, if that makes any sense... Try to think of X, Y and Z as independent entities, rather than Y being greater than X and Z being greater than Y, and thus greater than X. Perhaps replace them for apple, orange and banana instead.

• Good answer. I'd like to add two items. First, consider each column of the rotation matrix as mapping a new, moving coordinate system back to the old, stationary system. For example, the first column is the moving x vector expressed in the stationary coordinate system. If you look at the right-hand coordinate system picture, and rotate it 90 degrees about z (the thumb), you'll see that at that moment it is pointing in the positive y direction of the stationary system. But the moving y vector is now pointing in the negative x direction. I'll put the second item in another comment. Sep 21 '16 at 16:40
• The second item is that rotation matrices are orthonormal. Their determinant is always +1. This means they do not scale, stretch, or mirror anything. Since it is sin and cos functions that model the circular rotations about an axis, you will always end up with a determinant represented as a form of "sin^2 + cos^2". That results in 1. Think about the process for taking a determinant (top-to-bottom diagonals minus bottom-to-top diagonals is one approach). In order to get positive sin^2 plus positive cos^2, there has to be a minus sign in there somewhere. Sep 21 '16 at 16:45
• thank @Driessen for your answer. But when I derived rotation matrix for 2D in counterclockwise direction, I got matrix which is equal to your clockwise matrix. Youtube video link is attached with this. I follow the same method. link. Can you please explain me, where I am wrong? Sep 21 '16 at 19:44
• @Naseeb, I'm not sure where you make the mistake in the derivation, but given one of the two matrices (clockwise or counter-clockwise) you can easily find the other, and you'll see that they are not the same. If $\theta$ denotes clockwise rotation, then $-\theta$ denotes counter-clockwise rotation. It can then also be shown that $R_c(-\theta)=R_{cc}(\theta)$, because we know that $\cos{-\theta}=\cos{\theta}$ and $\sin{-\theta}=-\sin{\theta}$ Sep 21 '16 at 22:29
• Good points @SteveO! I suppose there are many things to say about rotation matrices; in the end they all correspond and we can only draw one conclusion: they make sense! Sep 21 '16 at 22:33

The real dig to the sign convention is direction and the way humans like to perceive things orderly or at least using a reference. clockwise and anti-clockwise directions only exist with 2D planes but the inherent nature of man's stubbornness would lead him to create the right-thumb-rule to support the notion of a 3D or 4D clock existing in the nearest future. other than that there is really nothing to it and I'd argue you can decide either of your sins(no pun intended) gets a minus or not(values along the diagonals are always preserved hence cos for any rotation matrix is always positive) because in higher dimensions there is no up or down, left or right except if assigned(with a bias) which is usually because humans are scared they must always be able to represent rotations in this form e.g. rotating a point from left to right or from bottom to top( where $$z$$ -> top, $$x$$ -> bottom(left), $$y$$ -> bottom(right) )

From the diagrams above 2D-perspective anti-clockwise ($$XY,YZ,ZX$$) and clockwise($$YX,XZ,ZY$$) rotations can be seen thus you can be sure that for your rotation matrix needs Rxy = -Ryx, Ryz = -Rzy and Rxz = -Rzx i.e.

$$XY$$-$$plane$$-$$rotation = - YX$$-$$plane$$-$$rotation$$,
$$YZ$$-$$plane$$-$$rotation = - ZY$$-$$plane$$-$$rotation$$,
$$XZ$$-$$plane$$-$$rotation = - ZX$$-$$plane$$-$$rotation$$

which implies they are opposite in direction and as per your taste you can as well decide you want your set of transformations to be e.g. $$XY, YZ, XZ$$(Rxy,Ryz,Rxz) instead of the matrices you provided earlier which corresponds to $$XY,YZ,ZX$$(Rxy,Ryz,Rzx) or by going even further to break all the rules you may decide $$YX,ZY,ZX$$(Ryx,Rzy,Rzx) is the most suitable for your maximum satisfaction

N.B When it's said that a 3D object is rotated via the z axis this means its plane of rotation was $$XY$$. I gave a better explanation here

The convention of these rotation matrices follow the same positive direction of rotation as the cross product in a right handed coordinate system.

So a 90° rotation around the x-axis maps the y-axis to the positive z-axis and the z-axis to the negative y-axis; a 90° rotation around the y-axis maps the z-axis to the positive x-axis and the x-axis to the negative z-axis; a 90° rotation around the z-axis maps the x-axis to the positive y-axis and the y-axis to the negative x-axis.