Today, a job to deal with coordinate transformation, a brief study.

Local coordinates to global coordinates

The principle is as follows:In this picture, the world coordinate system is
( X . Y . Z ) (X, Y, Z)
The local coordinate system is
( X . Y . Z ) (X’, Y’, Z’)
, origin of local coordinate system
O O’
. The point I want to convert to is
P P
.


O P = x i + y j + z k O O = a i + b j + c k OP =x*i+y*j+z*k \\ OO’=a*i+b*j+c*k

Coordinate axis correspondence


{ i = u 11 i + u 12 j + u 13 k j = u 21 i + u 22 j + u 22 k k = u 31 i + u 32 j + u 33 k \left\{\begin{matrix} i’=u_{11}*i+u_{12}*j+u_{13}*k \\ j’=u_{21}*i+u_{22}*j+u_{22}*k \\ k’=u_{31}*i+u_{32}*j+u_{33}*k \end{matrix}\right.

Simultaneous equation


O P = x i + y j + z k = x ( u 11 i + u 12 j + u 13 k ) + y ( u 21 i + u 22 j + u 22 k ) + z ( u 31 i + u 32 j + u 33 k ) = ( u 11 x + u 21 y + u 31 z ) i + ( u 12 x + u 22 y + u 32 z ) j + ( u 13 x + u 23 y + u 33 z ) k O’P=x’*i’+y’*j’+z’*k’\\ = \quad x’*(u_{11}*i+u_{12}*j+u_{13}*k) \\ \quad +y’*(u_{21}*i+u_{22}*j+u_{22}*k) \\ \quad +z’*(u_{31}*i+u_{32}*j+u_{33}*k) \\ = \quad (u_{11}*x’+u_{21}*y’+u_{31}*z’)*i \\ \quad + (u_{12}*x’+u_{22}*y’+u_{32}*z’)*j \\ \quad + (u_{13}*x’+u_{23}*y’+u_{33}*z’)*k

OP = + O ‘POP = OO OO’ ‘+ O’ POP = OO ‘+’ O P, then


{ x = a + u 11 x + u 21 y + u 31 z y = b + u 12 x + u 22 y + u 32 z z = c + u 13 x + u 23 y + u 33 z \left\{\begin{matrix} x=a+u_{11}*x’+u_{21}*y’+u_{31}*z’\\ y=b+u_{12}*x’+u_{22}*y’+u_{32}*z’\\ z=c+u_{13}*x’+u_{23}*y’+u_{33}*z’ \end{matrix}\right.

Transformation relation


[ x y z 1 ] = [ x y z 1 ] W \begin{bmatrix} x & y & z & 1 \end{bmatrix} = \begin{bmatrix} x’ & y’ & z’ & 1 \end{bmatrix} * W

Finally get the matrix


W = [ u 11 u 12 u 13 0 u 21 u 22 u 23 0 u 31 u 32 u 33 0 a b c 1 ] W= \begin{bmatrix} u_{11} & u_{12} & u_{13} & 0\\ u_{21} & u_{22} & u_{23} & 0\\ u_{31} & u_{32} & u_{33} & 0\\ a & b & c & 1 \end{bmatrix}

Global coordinates to local coordinates

because


[ x y z 1 ] = [ x y z 1 ] W \begin{bmatrix} x & y & z & 1 \end{bmatrix} = \begin{bmatrix} x’ & y’ & z’ & 1 \end{bmatrix} * W

then


[ x y z 1 ] W 1 = [ x y z 1 ] \begin{bmatrix} x & y & z & 1 \end{bmatrix} * W^{-1} = \begin{bmatrix} x’ & y’ & z’ & 1 \end{bmatrix}

The observed


W = [ u 11 u 12 u 13 0 u 21 u 22 u 23 0 u 31 u 32 u 33 0 a b c 1 ] = [ u 11 u 12 u 13 0 u 21 u 22 u 23 0 u 31 u 32 u 33 0 0 0 0 1 ] [ 1 0 0 0 0 1 0 0 0 0 1 0 a b c 1 ] = R T W= \begin{bmatrix} u_{11} & u_{12} & u_{13} & 0\\ u_{21} & u_{22} & u_{23} & 0\\ u_{31} & u_{32} & u_{33} & 0\\ a & b & c & 1 \end{bmatrix} = \begin{bmatrix} u_{11} & u_{12} & u_{13} & 0\\ u_{21} & u_{22} & u_{23} & 0\\ u_{31} & u_{32} & u_{33} & 0\\ 0 & 0 & 0 & 1 \end{bmatrix} \cdot \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0\\ a & b & c & 1 \end{bmatrix} =R \cdot T

Where RRR is the rotation matrix, TTT is the translation matrix so


W 1 = ( R T ) 1 = T 1 R 1 W^{-1}= (R\cdot T)^{-1} = T^{-1}*R^{-1}

Among them


T 1 = [ 1 0 0 0 0 1 0 0 0 0 1 0 a b c 1 ] T^{-1} = \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0\\ -a & -b & -c & 1 \end{bmatrix}

⋅R−1=ER \cdot R^{-1} =ER ⋅R−1=E. then


R 1 = R T = [ u 11 u 21 u 31 0 u 12 u 22 u 32 0 u 13 u 23 u 33 0 0 0 0 1 ] R^{-1}=R^{T}= \begin{bmatrix} u_{11} & u_{21} & u_{31} & 0\\ u_{12} & u_{22} & u_{32} & 0\\ u_{13} & u_{23} & u_{33} & 0\\ 0 & 0 & 0 & 1 \end{bmatrix}

W−1W^{-1}W−1 can be directly calculated.

However, if RRR is not a positive definite square matrix, that is, the axes of the local coordinate system are not perpendicular to each other in the right hand system, then the inverse is directly obtained to obtain W−1W^{-1}W−1.