Derivation of Coordinate System Transformation

TwoCoordinates

When a point in ss coordinates should be interpreted in another dd coordinates, the transformation matrix between coordinate systems is needed. That is, the point in ss coordinates is not moved and is just reinterpreted from the point of view of the dd system. This kind of transformation can be everywhere such as OC-to-WC or WC-to-EC. Technically, a point in ss coordinates can be rewritten as follows. (000)+xs(100)+ys(010)+zs(001)\begin{aligned} \left(\begin{array}{c} 0 \\ 0 \\ 0 \end{array}\right) + x_s \left(\begin{array}{c} 1 \\ 0 \\ 0 \end{array}\right) + y_s \left(\begin{array}{c} 0 \\ 1 \\ 0 \end{array}\right) + z_s \left(\begin{array}{c} 0 \\ 0 \\ 1 \end{array}\right) \end{aligned}

It implies that the point is located by moving xsx_s towards (1  0  0)t(1 \; 0 \; 0)^t, yxy_x towards (0  1  0)t(0 \; 1 \; 0)^t, and zsz_s towards (0  0  1)t(0 \; 0 \; 1)^t starting from the origin (0  0  0)t(0 \; 0 \; 0)^t. Let (ox  oy  oz)t(o_x \; o_y \; o_z)^t be the origin of dd coordinates. Then, the same point can be reinterpreted from the point of view of the dd coordinates. (oxoyoz)+xd(uxuyuz)+yd(vxvyvz)+zd(nxnynz)\begin{aligned} \left(\begin{array}{c} o_x \\ o_y \\ o_z \end{array}\right) + x_d \left(\begin{array}{c} u_x \\ u_y \\ u_z \end{array}\right) + y_d \left(\begin{array}{c} v_x \\ v_y \\ v_z \end{array}\right) + z_d \left(\begin{array}{c} n_x \\ n_y \\ n_z \end{array}\right) \end{aligned}

Considering that these two interpretations have the same meaning, (xsyszs)=(oxoyoz)+(uxvxnxuyvynyuzvznz)(xdydzd)    (xdydzd)=(uxvxnxuyvynyuzvznz)1((xsyszs)(oxoyoz))=(uxuyuzvxvyvznxnynz)((xsyszs)(oxoyoz))\begin{aligned} \left(\begin{array}{c} x_s \\ y_s \\ z_s \end{array}\right) &= \left(\begin{array}{c} o_x \\ o_y \\ o_z \end{array}\right) + \left(\begin{array}{ccc} u_x & v_x & n_x \\ u_y & v_y & n_y \\ u_z & v_z & n_z \end{array}\right) \left(\begin{array}{c} x_d \\ y_d \\ z_d \end{array}\right) \\\\ \implies \left(\begin{array}{c} x_d \\ y_d \\ z_d \end{array}\right) &= \left(\begin{array}{ccc} u_x & v_x & n_x \\ u_y & v_y & n_y \\ u_z & v_z & n_z \end{array}\right)^{-1} \left(\left(\begin{array}{c} x_s \\ y_s \\ z_s \end{array}\right) - \left(\begin{array}{c} o_x \\ o_y \\ o_z \end{array}\right)\right) \\\\ &= \left(\begin{array}{ccc} u_x & u_y & u_z \\ v_x & v_y & v_z \\ n_x & n_y & n_z \end{array}\right) \left(\left(\begin{array}{c} x_s \\ y_s \\ z_s \end{array}\right) - \left(\begin{array}{c} o_x \\ o_y \\ o_z \end{array}\right)\right) \end{aligned}

The last part is because uu, vv, and nn column vectors compose the orthonormal matrix. Using a homogeneous system, this result can be rewritten about the transform matrix MM. (uxuyuzvxvyvznxnynz)(oxoyoz)(txtytz)    (xdydzd1)=(uxuyuztxvxvyvztynxnynztz0001)(xsyszs1)    M=(uxuyuztxvxvyvztynxnynztz0001)=(uxuyuz0vxvyvz0nxnynz00001)(100tx010ty001tz0001)\begin{aligned} \left(\begin{array}{ccc} u_x & u_y & u_z \\ v_x & v_y & v_z \\ n_x & n_y & n_z \end{array}\right) \left(\begin{array}{c} o_x \\ o_y \\ o_z \end{array}\right) \equiv \left(\begin{array}{c} t_x \\ t_y \\ t_z \end{array}\right) &\implies \left(\begin{array}{c} x_d \\ y_d \\ z_d \\ 1 \end{array}\right) = \left(\begin{array}{cccc} u_x & u_y & u_z & -t_x \\ v_x & v_y & v_z & -t_y \\ n_x & n_y & n_z & -t_z \\ 0 & 0 & 0 & 1 \end{array}\right) \left(\begin{array}{c} x_s \\ y_s \\ z_s \\ 1 \end{array}\right) \\\\ \implies M = \left(\begin{array}{cccc} u_x & u_y & u_z & -t_x \\ v_x & v_y & v_z & -t_y \\ n_x & n_y & n_z & -t_z \\ 0 & 0 & 0 & 1 \end{array}\right) &= \left(\begin{array}{cccc} u_x & u_y & u_z & 0 \\ v_x & v_y & v_z & 0 \\ n_x & n_y & n_z & 0 \\ 0 & 0 & 0 & 1 \end{array}\right) \left(\begin{array}{cccc} 1 & 0 & 0 & -t_x \\ 0 & 1 & 0 & -t_y \\ 0 & 0 & 1 & -t_z \\ 0 & 0 & 0 & 1 \end{array}\right) \end{aligned}

Note that uu, vv, and nn are set as row vectors in MM. More importantly, MM has an intuitive interpretation that it pulls the origin of dd coordinates to the origin of ss coordinates and then spins the three axes of dd coordinates to fit the axes of ss coordinates.

Sometimes, it is very confusing whether to set uu, vv, and nn as row vectors or column vectors. Here is a tip. uu, vv, and nn that are defined in ss coordinates should be the standard basis in dd coordinates. So, the following simple calculation may help to set directions. Let M33M_{33} be the 3×33 \times 3 submatrix of MM. M33(uxuyuz)=(100),M33(vxvyvz)=(010),M33(nxnynz)=(001)\begin{aligned} M_{33} \left(\begin{array}{c} u_x \\ u_y \\ u_z \end{array}\right) = \left(\begin{array}{c} 1 \\ 0 \\ 0 \end{array}\right), \qquad M_{33} \left(\begin{array}{c} v_x \\ v_y \\ v_z \end{array}\right) = \left(\begin{array}{c} 0 \\ 1 \\ 0 \end{array}\right), \qquad M_{33} \left(\begin{array}{c} n_x \\ n_y \\ n_z \end{array}\right) = \left(\begin{array}{c} 0 \\ 0 \\ 1 \end{array}\right) \end{aligned}

Note that u=v=n=1\lVert u \rVert = \lVert v \rVert = \lVert n \rVert = 1 and uv=vn=un=0u \cdot v = v \cdot n = u \cdot n = 0.

Reference

[1] 3D Graphics Programming Using OpenGL: Introduction


© 2024. All rights reserved.