Mapping local coordinates to global coordinates

9.4.1. Mapping local coordinates to global coordinates#

Let’s start with this example, where we want to express the yellow point of Fig. 9.13 in global coordinates.

Fig. 9.13 Expressing a local point in global coordinates.#

The unknown is the yellow point’s coordinates with respect to the global frame:

(9.1)#\[ ^\text{global} p = \text{?} \]

Instead of considering point \(p\) as a point in its own local coordinate system, let’s imagine that it was first expressed in the global reference frame (\(^\text{global} p_\text{initial}\)). Then, it was rotated by 30 degrees around the origin, then translated by (7, 5, 0) to reach its final position (\(^\text{global} p_\text{transformed}\)), as shown in Fig. 9.14.

Fig. 9.14 Transformation sequence from local coordinates to global coordinates.#

This operation is expressed by:

(9.2)#\[ ^\text{global} p_\text{transformed} ~~~ = ~~~ T ~~~ ^\text{global} p_\text{initial} \]

where \(T\) represents a rotation of 30 degrees and a translation of (7, 5, 0) units.

Now, let’s put Fig. 9.13 and Fig. 9.14 in relation.

The first image of Fig. 9.14 expresses the yellow point in its local reference frame. Therefore:

(9.3)#\[ ^\text{global} p_\text{initial} = ^\text{local} p \]

The last image of Fig. 9.14 expresses the yellow point in global coordinates. Therefore:

(9.4)#\[ ^\text{global} p_\text{transformed} = ^\text{global} p \]

By substituting (9.3) and (9.4) into (9.2), we get:

\[ ^\text{global} p = T ~~~ ^\text{local} p \]

where T, which was formerly interpreted as the transformation applied in Fig. 9.14, is now interpreted as the local reference frame itself: a coordinate system that has been rotated by 30 degrees and translated by (7, 5, 0) units.

We see that if we know the local coordinates of a point \(^\text{local} p\), and we know the coordinates of its local reference frame \(T\), then the global coordinates of the point are obtained simply by multiplying \(T\) and \(^\text{local} p\).

Now, let’s solve the problem. We know the yellow point’s coordinate (2, 1, 0) in respect to the local frame:

\[\begin{split} ^\text{local}p = \begin{bmatrix} 2 \\ 1 \\ 0 \\ 1 \end{bmatrix} \end{split}\]

We also know how to express the local frame as a homogeneous transform:

\[\begin{split} ~^\text{global}_\text{local}T = \begin{bmatrix} \cos(30) & -\sin(30) & 0 & 7 \\ \sin(30) & \cos(30) & 0 & 5 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \end{split}\]

Therefore:

\[\begin{split} ^\text{global}p = \begin{bmatrix} \cos(30) & -\sin(30) & 0 & 7 \\ \sin(30) & \cos(30) & 0 & 5 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} 2 \\ 1 \\ 0 \\ 1 \end{bmatrix} \\= \begin{bmatrix} 0.866 & -0.5 & 0 & 7 \\ 0.5 & 0.866 & 0 & 5 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} 2 \\ 1 \\ 0 \\ 1 \end{bmatrix} = \begin{bmatrix} 8.232 \\ 6.866 \\ 0 \\ 1 \end{bmatrix} \end{split}\]

The position of the yellow point, in global coordinates, is (8.232, 6.866, 0).