Me and my friend have ran into trubbels with translating a point in a 3D-space from one cartesian coordinate system to another.

In this case we have 3 coordinate systems called the Base-frame, h-frame and b-frame (see picture below). From the Base-frame we rotate with $\pi$ around the Base-frame x-axis in order to reach the h-frame. This is done with the following transformation matrix:

$ T_{base}^h = \begin{bmatrix} 1,\ \ 0,\ \ 0,\ \ 0\\0,-1,\ \ 0,\ \ 0\\0,\ \ 0,-1,\ \ 0\\0,\ \ 0,\ \ 0,\ \ 1 \end{bmatrix}$

When this has been done we rotate from the h-frame to the b-frame by rotating around the h-frame x-axis with $\frac{\pi}{2}$ with the following matrix:

$ T_{h}^b = \begin{bmatrix} 1,\ \ 0,\ \ 0,\ \ 0 \\ 0,\ \ 0,-1,\ \ 0\\ 0,\ \ 1,\ \ 0,\ \ 0\\0,\ \ 0,\ \ 0,\ \ 1 \end{bmatrix}$

We then want to express a coordinate, expressed in the Base-frame, say $coord_{base} = [1;1;0;1]$, in the b-frame (last 1 just for size). With the knowledge of the frames orientation the point [1;1;0;1] expressed in the Base-frame, should become [1;0;1;1] in the b-frame. To get this point with the help of our matrices, we perform the following calculation

$coord_{b} = T_{base}^h \ \ T_{h}^b \ \ coord_{base}$

this, however, yields the point [1;0;-1], and not [1;0;1] as expected. Why? Are we multiplying in the wrong order? Creating the rotation matrices in the wrong order? Are we missing something obvious here?

Picture of frames and their rotation

Grateful for all help we can get!

  • 1
    $\begingroup$ The matrices are being multiplied in the wrong order. $\endgroup$ – greg Oct 11 '18 at 14:37
  • $\begingroup$ If you compare the last set of coordinate axes with the first set, it's clear that the end result of these two rotations is the same as if you just did a rotation by $\phi=-\frac\pi2$ around the $x$ axis and did no other rotation afterward. Of course that observation will not help much with any example where the rotations are not all around one axis; then you would still need to pay attention to the order of multiplying the matrices. $\endgroup$ – David K Oct 12 '18 at 0:23
  • $\begingroup$ You are correct, but in our case the angle between h-frame and b-frame will vary (in the end), so we can not take this route. $\endgroup$ – user603025 Oct 12 '18 at 12:35

To expand a bit on greg’s comment, yes, you’ve got the matrices in the wrong order. Think about it this way: After transforming $\mathbf x_{base}$ into the $h$-frame, you have $T_{base}^h\mathbf x_{base}$. You then transform this into the $b$-frame, you multiply this by the next transformation matrix, getting $T_h^b(T_{base}^h\mathbf x_{base})$.

More generally, if you’re representing points as column vectors, then you left-multiply by the transformation matrix and the transformation cascade grows leftward; if you’re using row vectors, you right-multiply by the matrix and the cascade grows rightward.


Thank you for your replies!

However, even when if we change the order of the multiplication from $T_{base}^{h} \ T_{h}^b \ coord_{base}$ to $T_{h}^{b} \ T_{base}^{h} \ coord_{base}$, we still get the same (wrong) answer, which is $coord_b = [1;0;-1]$. This made us believe that the frames somehow got rotated wrongly along the way, and that the b-frame especially had been flip $\pi$ around the x-axis. That would explain the coordinate we get. After redoing the calculations in Matlab, as seen below, we did however find out that this was NOT the case. The b-frame is oriented the same way as in the picture provided earlier. How come the point doesn't "understand" this?

%Creation of transformation matrices

T_base_h = [1, 0, 0, 0 ; 0, -1, 0, 0 ; 0, 0, -1, 0 ; 0, 0, 0, 1];

T_h_b = [1, 0, 0, 0; 0, 0, -1, 0; 0, 1, 0, 0; 0, 0, 0, 1];

% Base frame

coord_base = [1;1;0;1]

frame_base = [1,0,0; 0,1,0; 0,0,1];

% h-frame

coord_h = T_base_h * coord_base;

frame_h = frame_base * T_base_h(1:3,1:3)

% b-frame

coord_b = T_h_b * coord_h;

frame_b = frame_h * T_h_b(1:3,1:3)


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.