# How to convert from Object space into World space (exercise from 3D Math Primer book)

This is not homework. I'm self studying Computer Graphics, using the book "3D Math Primer for Graphics and Game Development" (2nd edition). So there is the exercise 6 in chapter 3 which I can't figure out how to solve exactly. It goes like this:

"Assume that the robot is at the position (1, 10, 3), and her right, up, and forward vectors expressed in upright space are [0.866, 0, −0.500], [0, 1, 0], and [0.500, 0, 0.866], respectively. (Note that these vectors form an orthonormal basis.) The following points are expressed in object space. Calculate the coordinates for these points in upright and world space. (a) (−1, 2, 0) (b) (1, 2, 0) ..."

Now I know that in order to convert from Object space to world space I have to first convert into inertial/upright space by performing a rotation and then into world space by performing a translation. So I assume that that the point (1,10,3) is expressed in world space coordinates. What I don't understand is which one is the matrix I have to use to do the rotation on point (-1,2,0)? I understand conceptually what is going on but I don't know which operations to do here. Help is greatly needed and will be appreciated. Thanks in advance.

• If you are having difficulties on the algebra side, I would like to suggest that you see 3Blue1Brown videos on linear algebra that are available on Youtube. They will give you all the geometric intuition you need to understand transformation matrices. – vgs May 9 '19 at 22:34

For others who might have this question, here a perhaps more straight forward numeric answer (I'm now working myself on this book as well). Consider that:

1. We are given object space coordinates that need to be transformed into upright and subsequently world space coordinates.

2. We know that a vector $$\vec{v}$$ can be represented as a linear transformation of its axises in relation to the set of basis vectors $$\vec{p}$$, $$\vec{q}$$, $$\vec{r}$$, when these are orthonormal (perpendicular to each other and with length $$l = 1$$)

3. The equation to represent this is thus: $$\vec{v} = v_{x}p + v_{y}q + v_{z}r$$

4. Given the basis vectors we can computed this for each object reference using the above equation. So, the first example would be:

$$\vec{u} = -1 \begin{bmatrix}0.866\\ 0\\ -0.500 \end{bmatrix} + 2 \begin{bmatrix}0\\ 1\\ 0\end{bmatrix} + 0 \begin{bmatrix}0.500\\ 0\\ 0.866\end{bmatrix} = \begin{bmatrix}-0.866\\ 2\\ 0.500\end{bmatrix}$$

Then, to compute this in world space, you simply need to add your world space reference to the upright vector. Meaning:

$$\vec{w} = o + u$$

For the first example in the book that would be:

$$\vec{w} = \begin{bmatrix}1\\ 10\\ 3\end{bmatrix} + \begin{bmatrix}-0.866\\ 2\\ 0.500\end{bmatrix} = \begin{bmatrix}0.134\\ 12\\ 3.500\end{bmatrix}$$

Let me try to translate the problem statement in a mathematical way so that it can be understood more easily.

Assume that the robot is at the position (1, 10, 3)

Assume there are a set of basis $$\mathbf{e}_i$$ and origin $$\mathbf{O}$$, then the robot position $$\mathbf{P}$$ expressed in this basis is the origin plus a linear combination of the basis and the coefficients $$\mathbf{p}=(1,10,3)$$: $$\mathbf{P}=p_i \mathbf{e}_i + \mathbf{O}$$

and her right, up, and forward vectors expressed in upright space are [0.866, 0, −0.500], [0, 1, 0], and [0.500, 0, 0.866], respectively.

Now we have another set of basis denoted as $$\mathbf{e}'_i$$ attached at $$\mathbf{P}$$, and the relation between these two basis $$\mathbf{e}$$ and $$\mathbf{e}'$$ are also expressed as linear combinations. That is, denote $$\mathbf{m}_0=(0.866,0,-0.5)$$,$$\mathbf{m}_1=(0,1,0)$$, and $$\mathbf{m}_2=(0.5,0,0.866)$$, then $$\mathbf{e}'_i=m_{ij} \mathbf{e}_j$$

Calculate the coordinates for these points in upright and world space. (a) (−1, 2, 0) (b) (1, 2, 0) ...

The given coordinates are in object space and the problem asks us to compute their representations in frames $$\{\mathbf{e}_i,\mathbf{P}\}$$ and $$\{\mathbf{e}_i,\mathbf{O}\}$$ respectively.

Take $$\mathbf{x}=(-1,2,0)$$ as an example, we want to find the coordinates $$\mathbf{l}$$ in upright space: \begin{align} x_i \mathbf{e}'_i + \mathbf{P} &= l_i \mathbf{e}_i + \mathbf{P}\\ x_j m_{ji} \mathbf{e}_i &= l_i \mathbf{e}_i \end{align} Written in matrix form: $$\mathbf{M}^T \mathbf{x}=\mathbf{l}$$.

Next we find the coordinates $$\mathbf{w}$$ in world space: \begin{align} x_i \mathbf{e}'_i + \mathbf{P} &= w_i \mathbf{e}_i + \mathbf{O} \\ x_i \mathbf{e}'_i + p_i\mathbf{e}_i &= w_i \mathbf{e}_i \\ x_j m_{ji} \mathbf{e}_i + p_i\mathbf{e}_i &= w_i \mathbf{e}_i \\ x_j m_{ji} + p_i &= w_i \end{align} Written in vector form: $$\mathbf{M}^T \mathbf{x} + \mathbf{p} = \mathbf{w}$$

Your idea is generally correct. And the "upright" matrix can be constructed by considering the relation ($$m_{ij}$$) between the two basis, as shown above.

• Thanks for the answer, but are you sure you haven't confused even yourself with so much symbolism (because I certainly have)? I did understand though. Thanks. – Nikos Oct 13 '19 at 10:23