# Correctness of logical steps for create the matrix of viewing transformation

In general, I understand the creation of viewing transformation matrix, but I have my doubts.

For example, let's say that a world coordinate (called $A$) has a center at $(1,1,1)$, and the view reference point (VRP) (called $B$) has a center at $(3,3,2)$.

Each vertex of the world must be "mapped" to $B$. The axes of $A$ and $B$ aren't aligned so a translation isn't enough, but there are two necessary rotations (around $x$ and $y$ of two certain angles).

I want to know if I am proceeding in a correct way. For overlapping the axes from $A$ to $B$ these are the following steps:

1. translate (transformation $T$) with translation parameters $(2,2,1)$, namely $(3-1,3-1,2-1)$
2. rotation around $x$ (transformation $R_x$)
3. rotation around $y$ (transformation $R_y$)

Thus, the transformation is: $R_yR_xT$ when $T$ is the first matrix which must be applied. Thus, the transformation to "map" a point of $A$ into the the corresponding point in $B$ coordinates is the inverse namely: $(T^{-1})(Rx^{-1})(Ry^{-1})$

My main doubt is if it's correct, for converting $A$ and $B$, to do a translation first.

In general, is this process correct?

I'm assuming you mean $A$ is object$\rightarrow$world matrix and $B$ is your camera$\rightarrow$world matrix? If that's the case, to calculate object object$\rightarrow$camera matrix you calculate:

$$C=B^{-1}*A$$

In general your math is correct, i.e. the order of matrix multiplication is reversed for the inverse calculation. It's just that normally these transformations are combined to a single 4x4 transformation matrix which does rotation, scaling and translation, and then you just work with that single matrix instead of it being decomposed to separate rotation & translation matrices. Anyway, if you want to decompose the matrix multiplication, based on the above you would do:

$$A=T_A*Ry_A*Rx_A$$ $$B=T_B*Ry_B*Rx_B$$ $$C=Rx_B^{-1}*Ry_B^{-1}*T_B^{-1}*T_A*Ry_A*Rx_A$$

• No,no! A is the world reference system (the coordinate system, Oxyz) and B is the reference system of the camera (Ouvn). Maybe I had not specified. In light of these explanations it is correct what I said in my original post? – Umbert Oct 11 '16 at 21:45
• @Umbert why would world be anything other than identity? I mean lack of identity world would mean there is something more fundamental than world in the scene. So the identity basis is present no matter what even if its below your world meaning world is a object space of somekind. There is always a explicit assumption that something identity is at the lowest level of a transformation chain. – joojaa Oct 12 '16 at 3:39
• @Umbert It's important to say coordinate system relatively to what. "World" is usually considered global "root" frame joojaa explained in his answer. If $A$ is transformation to your "world" then where is it transformation from? Global frame? The answer I gave still holds if both $A$ and $B$ are defined relatively to the same frame, just use different names (world=global frame, object=world). – JarkkoL Oct 12 '16 at 12:25

I would like to address an issue in your naming. This issue makes the question a bit odd, but not impossible, as I will try to show.

There is an, often unspoken, implied relationship between the matrices. For a matrix to be meaningful there has to be a common ancestor of the matrix that all matrices relate to. See a transformation chain works like a disk system or the root node of a XML document. There is always a base node, in computer graphics texts we choose to call this node World*. Calling something else world is just defining your own definition of things. Image 1: The implied hierarchy of matrices, we have agreed to name the root World.

Now there is assumed to be nothing outside the world. Although just like zeroes before numbers there is a possibility of infinite worlds within worlds, but those extra worlds do not participate in our model so they hardly matter.

The hierarchy determines how the matrices interact with each other. All matrices are identity matrices ($I$) when viewed from inside the object. Therefore we have the following property for world:

$$T_{world} = I.$$

Anything else would imply that World is not World but rather an object as @JarkkoL's answer implies, so there is yet another World outside what you call World. Also because world is the identity it can be omitted from your calculations, which is why it's sometimes left unnamed.

Now it is obviously possible to name objects. This is smart as it makes talking about things easier. So you could call a bicycle object object "bicycle", makes sense. In fact we do this by calling the camera, "Camera". These names are arbitrary, so it is possible to call an object space World. But then the discussion just drops into confusion.

Now we can address the confusion as your description is ambiguous. This is also is why you have problems reasoning about this. So either what you describe is like: Image 2: Since you have renamed World we do not know what your relationship is.

So by reinventing naming convention you have made the question confused. If you had not then there would be a really easy rule you would append the multiplication as normal as long as you move towards the world and inverted if you move away from the world.

* There are traditions where this is called the Inertial frame, Reference Frame and even sometimes rarely Base.

• My question is simple. I must aplly the view transfrormation. I supposed that the matrix for pass from Object space to world has already been applied.Thus I'm in world coordinates (Oxyz).I must pass in camera coordinates (Ouvn).(change of coordinates)Then I overlap the 3 axes (x,y,z) on 3 axes (u,v,n) with a transformation namely RxRyT. Later for map a point P of the coordinate system of the world (Oxyz) to the Ouvn I do (T^-1)*(Ry^-1)*(Rx^-1)*P . My doubt is: is right the transformation RxRyT for ovelaps the 2 axes?Or the right transformation is TRxRy and then (Ry^-1)*(Rx^-1)*(T^-1)P? – Umbert Oct 13 '16 at 10:38