How to find the rotation matrix between two coordinate systems?
Asked Answered
C

4

35

There are two coordinate systems. We know the 3D coordinates of the origin and the 3D vectors of the axes of the second coordinate system with respect to the first coordinates system. Then how can we find the rotation matrix that transforms the first coordinate system into the second coordinate system?

enter image description here

Catlett answered 21/12, 2015 at 8:57 Comment(0)
L
16

The problem described can be solved as follows. Let

M = m_11 m_12 m_13
    m_21 m_22 m_23
    m_31 m_32 m_33

denote the desired rotation matrix. We require

 1 0 0 * M + t = x_x x_y x_z
 0 1 0           y_x y_y y_z
 0 0 1           z_x z_y z_y

where t denotes the translation; we see that this matrix equality can be solved by multiplying from the left with the identity matrix, which is the inverse of itself; hence we obtain the following equality.

 M + t = x_x x_y x_z
         y_x y_y y_z
         z_x z_y z_y

This can be rearranged by subtracting t from both sides to obtain the desired matrix M as follows.

 M = x_x x_y x_z - t = x_x-t_x x_y-t_y x_z-t_z 
     y_x y_y y_z       y_x-t_x y_y-t_y y_z-t_z
     z_x z_y z_y       z_x-t_x z_y-t_y z_z-t_z

Note that this was relatively easy as the initial matrix consists out of the basic vectors of the standard base. In general it is more difficult and involves a basis transformation, which basically can be done by Gaussian elimination, but can be numerically difficult.

Langelo answered 21/12, 2015 at 9:27 Comment(6)
Note that for rotation matrix one should subtract translation vector from all columns of M, so `R = x_x - x x_y - x x_z - x ...' and so onBarthol
I'm not familiar with the used notation; does t denote an involved translation? It makes sense, however the original question demands for a rotation only.Langelo
I think yes, author's [R|t] implies rotation+translation (note non-zero origin). Your matrix M is correct for pure rotation case, for R+t it is necessary to use relative coordinatesBarthol
Yes, [R|t] implies the rotation and translation. Do we need to subtract the translation vector (t) from matrix M. I think there is no relationship between the 3D vectors of the three axes and the origin. (x_x, x_y, x_z) is a 3D vector that represents only the direction of the X-axis with respect to the coordinate system 1. That vector will be same even there is no translation.Catlett
@Catlett The translation has to be taken care of separately, as a translation cannot be represented by matrix multiplication (at least nt within the same dimensions). For this reason, usually affine transformation is used (in which an additional dimension is introduced artificially, which is later removed by projection) - as a consequence, all desired transformations (rotating, scaling and translating) can be represented as matrix multiplication.Langelo
further question: from the rotation matrix, what's the best strategy to find the Euler angles of rotation (i.e alpha, beta, gamma)?Mccarthy
V
1

I think the change of basis could help youWiki Link. Its quite easy to implement.

Vespertine answered 6/6, 2016 at 7:24 Comment(0)
A
0

The rotation matrix is simply -

R = [x_x, y_x, z_x; x_y, y_y, y_z; z_x, z_y, z_z]

The reason is that the columns of a rotation matrix of one coordinate system with respect to any other coordinate systems are just the columns of axes of the first coordinate system with respect to the other coordinate system.

So, if you want to calculate a rotation matrix R of B coordinate system with respect to A coordinate system, the columns of R will be just the axes of B in A.

Aut answered 13/4 at 14:35 Comment(0)
F
-2

Let A be the 4x4 matrix defining the relationship between the two coordinate systems.

Then the angle between the two is:

θ = arcos(trace(A)/2.0)

Finedraw answered 17/10, 2018 at 14:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.