I'm trying to concatenate a rotation matrix with a 4x4 homogeneous transformation matrix with column-major convention.

I want this rotation matrix to perform a rotation about the X axis (or YZ plane) by an angle theta in a 3D space.

$$ \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & \cos{\theta} & -\sin{\theta} & 0 \\ 0 & \sin{\theta} & \cos{\theta} & 0 \\ 0 & 0 & 0 & 1 \\ \end{pmatrix} $$

I use column-major matrices so I know I have to post-multiply them to concatenate them.

$$ \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & \cos{\theta} & -\sin{\theta} & 0 \\ 0 & \sin{\theta} & \cos{\theta} & 0 \\ 0 & 0 & 0 & 1 \\ \end{pmatrix} \begin{pmatrix} x_x & y_x & z_x & \Delta_x \\ x_y & y_y & z_y & \Delta_y \\ x_z & y_z & z_z & \Delta_z \\ 0 & 0 & 0 & 1 \\ \end{pmatrix} $$

It gives me: $$ \begin{pmatrix} x_x & y_x & z_x & \Delta_x \\ x_y \cos{\theta} - x_z \sin{\theta} & y_y \cos{\theta} - y_z \sin{\theta} & z_y \cos{\theta} - z_z \sin{\theta} & \Delta_y \cos{\theta} - \Delta_z \sin{\theta} \\ x_y \sin{\theta} + x_z \cos{\theta} & y_y \sin{\theta} + y_z \cos{\theta} & z_y \sin{\theta} + z_z \cos{\theta} & \Delta_y \sin{\theta} + \Delta_z \cos{\theta} \\ 0 & 0 & 0 & 1 \\ \end{pmatrix} $$

Which is obviously wrong but I don't know how to get it to work with respect with the column-major convention...

EDIT: What is my goal?

What I want to do is to concatenate my rotation matrix $R$ and a transformation matrix $T$ (which can have translation, rotation, scaling...) by using matrix product $C = R * T$ so that when I'll apply this matrix to a 3D (homogenous) set of points, the points will be transformed in accordance with both $T$ and $R$.

I think the above result matrix is wrong because as you can see, the location point $\Delta$ is affected by the rotation while I didn't expect it to be. Indeed, I just want points to be rotated in relation to an arbitrary object upright space not the world space.

I would expect column 2 and 3 to be modified instead of row 2 and 3. Reversing the matrix product $C = T * R$ could solve the problem but I was told that as far I use column-major convention, I have to post-multiply transformations.

Maybe I'm completely wrong and matrix concatenation has nothing to do with whether I pre- or post- multiply them... In fact, it may just specify in which order to apply transformations (first rotate with $R$, then transfroms with $T$...)

Can you tell me if I'm wrong somewhere?


By "column major convention," I assume you mean "The things I'm transforming are represented by $4 \times 1$ vectors, typically with a "1" in the last entry. That's certainly consistent with the second matrix you wrote, where you've placed the "displacement" $\Delta$ in the last column. Your entries in that second matrix follow a naming convention that's pretty horrible -- it's bound to lead to confusion.

Anyhow, the matrix product that you've computed is correct (that is, you did the multiplication properly). The result is something that first translates the origin to location $\Delta$ and the three standard basis vectors to the vectors you've called $\vec{x}$, $\vec{y}$, and $\vec{z}$, respectively, and having done so, then rotates the result in the $(2,3)$-plane of space (i.e., the plane in which the second and third coordinates vary, and the first is zero. Normally, I'd call this the $yz$-plane, but you've used up the names $y$ and $z$.) The rotation moves axis 2 towards axis 3 by angle $\theta$.

I don't know if that's what you want or not, but it's what you've got. Perhaps if you described the goal more clearly I could give a clearer answer.

  • $\begingroup$ Thanks John for your answer. You have successfully understood the conventions I used. I've edited the post to explain what I want to do more precisely. $\endgroup$ – neeh Feb 18 '14 at 12:31
  • $\begingroup$ Saying "the points will be transformed in accordance with both $T$ and $R$" is too vague. Your current solution transforms points "in accordance with both $T$ and $R$," because "in accordance with" is too vague to be meaningful. Can you be explicit? Suppose $T$ is translation along the $z$-axis by $+3$ units, so that $T(origin) = (0,0,3)$. Suppose that $R$ is rotation from $z$ towards $y$ by 90 degrees. How should the transformation transform (a) the origin, (b) the point $(1,0,0)$ that's one unit along the $x$-axis, and (c) the point $(0, 1, 0)$? $\endgroup$ – John Hughes Feb 18 '14 at 13:52
  • $\begingroup$ I deal with two spaces, all my 3D points are given in a "local space". $T$ is the matrix that transforms my 3d points from local space to world space. The point $a(0,0,0)$ in local space ($(0,0,3)$ in world space) isn't affected by the rotation (origin). $b(1,0,0)$ (or $(1,0,3)$ in world space) isn't affected by the rotation (rotation about X-axis). $c(0,1,0)$ (or $(0,1,3)$ in world space) should be transformed to $a'(0,0,-1)$ in local space or $(0,0,2)$ in world space. I made a picture to show the transformation postimg.org/image/j3jyf3sx7 $\endgroup$ – neeh Feb 18 '14 at 18:35
  • $\begingroup$ This example has confirmed me that the concatenation of a transformation matrix and a rotation matrix (column-major) should be written $C = T * R$ (At least in my case) even if I don't really understand why... $\endgroup$ – neeh Feb 18 '14 at 18:43
  • $\begingroup$ Well, I guess I've been of some service, then. When you write $C = T * R$, the $R$ is being applied to your modeling coordinates, i.e., it's a rotation in local space; $T$ then transforms the resulting points to world-space. Why? A typical modeling coordinate-vector $v$ is transformed to $S(v) = T(R(v))$. So $T$ is applied to $R(v)$, which is $v$, rotated in modeling coordinates (because $T$ has not yet been applied). $\endgroup$ – John Hughes Feb 18 '14 at 20:14

Since the right matrix factor $T$ is actually a so-called affine transformation, it looks like you are seeking for some general homogeneous rotation formulation because there is no such generalized formulation available for arbitrary rotation axis cases(not necessarily through system origin).

If so, please refer to answers below another thread: About homogeneous rotation

As a matter of fact, there are similar general formula to more basic geometric transformations, while the concepts of local and world coordinate systems, and the transformations between such kind of reference systems may be obsolete.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.