<p>I think the naming order is intuitive because it is in reading order (left to right), e.g., worldViewProjection means that your point/direction is first multiplied by the world matrix, then the view matrix, and then the projection matrix. In this manner, you know the correct multiplication order by just reading the variable name and you do not have to think about mathematics at all. In your case, I think the problem is that your intuition seems to be focused on how you write the equations on paper or code.</p>

<p>The idea that a point is a column vector and matrices are multiplied on the left is also just a mathematical convention that you are used. You can use a row vector and multiply on the right by the transpose matrix, and the math is exactly the same, but would imply a reverse writing order in compound transformations. Some people just prefer one notation over the other.</p>

<p>I have read some old computer graphics books that use row vectors as points/directions, but it seems that most modern books have converged on using column vectors. IMHO, maybe this change during the years is one of the sources of confusion for so many new CG students.</p>

<p>For instance, if you choose to represent points as row vectors you would write something like this in your code: <strong>new_point = point * world * view * projection</strong>. On the other hand, if you use column vectors you would write this: <strong>new_point = projection * view * world * point</strong>. The important thing is that these matrices must not be the same, that is, the world matrix in the first code is the transpose of the world matrix in the second code, and the same is true for the others. As you can see, if you choose one math convention over the other, this will probably have influence on your naming conventions while writing your code.</p>

CC BY-SA 3.0
2016-07-19T23:21:29.547Z
2016-07-19T23:32:55.590Z
2016-07-19T23:32:55.590Z
vgs
<p>The order is arbitrary, but if you want to be compatible with physics textbooks then your notation is mostly set. The difference is that you seem to think that its more natural to observe the systen on the outside (and for graphics pipe devs its often so, not for modeler). For a mathematician it is more natural to think from local coordinates out. There are several reasons for this but mathematician seem to want to reduce this to functional form if you were to transform a value x through multiple functions you would get:</p>

<p>$$
h(g(f(x))) 
$$</p>

<p>or sometimes</p>

<p>$$
(h \circ g \circ f)(x)
$$</p>

<p>This quite literary means transform x to f to g to h. So it is natural for a mathematician/physicist and some programmers to read the operations inside out simplybbecause this ties in better with the notation you were teached in early calculus. This way your operational order matches also other branches of mathematical notation. Since most math and physics textbooks take this approach you probably should too. </p>

<p>The other reason is that your modeling elements lie on the outside of your data. But obviously you are free to transpose your vectors and then your order is opposite. It is up to you to define meaning to your math. This because there is  a rule that follows from how matrices are defined that states:</p>

<p>$$
(A \cdot B)^T = B^T \cdot A^T
$$</p>

<p>It is easily shown that longer chains just reverse the entire chain by recursing this forumula.</p>

<p>It is good to remeber that the order inside the vectors are arbitrary as well as calculation order. There is no reason for the vector to be defined in X, Y, Z, W order we could define the matrices and vectors in any order even a slightly cryptic X, W, Z, Y order. So rember the modeling convention is not somehow set in stone. Students would often want it to be, because that would mean not needing to understand as much, but it does not have to be. Matrices just enable you to model arbitrary vectors with unified math notation. </p>

CC BY-SA 3.0
2016-07-20T08:44:00.260Z
2016-07-20T09:15:21.853Z
2016-07-20T09:15:21.853Z
joojaa
<p>I'm probably going to screw this up but.... In all the graphics libraries I've seen various matrices are often called something along the lines of</p>

<pre><code>viewProjection
modelViewProjection
worldViewProjection
mvp
wvp
</code></pre>

<p>etc.</p>

<p>But, that seems unintuitive given that GLSL, HLSL, and most math libraries seem to multiply in the opposite direction.</p>

<p>In other words</p>

<pre><code>viewProjection = projection * view;  // correct but unintuitive
</code></pre>

<p>vs</p>

<pre><code>viewProjection = view * projection;  // incorrect but naming matches order
</code></pre>

<p>It gets worse if you add in transpose or inverse since now the order of operations vs the order of parts of the name of the matrix make zero sense whatsoever. a <code>worldViewProjectionInverseTranspose</code> would be</p>

<pre><code>transpose(inverse(projection * view * world))
</code></pre>

<p>Well you can read it backward but as far as order of operations and position in the expression its </p>

<pre><code>5 ( 4 ( 1 * 2 * 3 ) )
</code></pre>

<p>Is there any objective reason for the names to be backward from the operations that construct them or is it just some naming convention that stuck from some example lost in obscurity?</p>

<p>I'm asking this question because being that it's unintuitive I find it's always hard to remember the order. If <code>worldViewProjection</code> equaled <code>world * view * projection</code> it would be easy since the name matches the order. I'm hoping there's some other objective reason that might help remember vs just remembering always multiply backward from the order of the parts of the commonly used names.</p>

CC BY-SA 3.0
2016-07-20T03:43:47.190Z
See code above. We are not multiplying by world first. Even if you have a matrix stack it's always projection first if you were to put it in the stack. Maybe in your mind we are but in code we are not. If you were to write `a = b + c + d` no one would describe that as adding `d` first
gman
CC BY-SA 3.0
2016-07-20T05:44:40.087Z
Personally I would prefer more explicit naming conventions. For example:   
`worldToScreen = worldToView * viewToScreen` , or   
`screenPosition = worldToScreen * worldPosition` ...
wip
CC BY-SA 3.0
2016-07-20T07:58:47.347Z
Can we just blame this on the fact we multiply right-to-left while reading from left-to-right ?
PaulHK
<transformations><glsl><hlsl>
Is there a objective reason for matrix naming conventions?
gman
# Is there a objective reason for matrix naming conventions?

(Asked by: username_0 on 2016-07-19)

I'm probably going to screw this up but.... In all the graphics libraries I've seen various matrices are often called something along the lines of

```
viewProjection
modelViewProjection
worldViewProjection
mvp
wvp

```

etc.

But, that seems unintuitive given that GLSL, HLSL, and most math libraries seem to multiply in the opposite direction.

In other words

```
viewProjection = projection * view;  // correct but unintuitive

```

vs

```
viewProjection = view * projection;  // incorrect but naming matches order

```

It gets worse if you add in transpose or inverse since now the order of operations vs the order of parts of the name of the matrix make zero sense whatsoever. a `worldViewProjectionInverseTranspose` would be

```
transpose(inverse(projection * view * world))

```

Well you can read it backward but as far as order of operations and position in the expression its

```
5 ( 4 ( 1 * 2 * 3 ) )

```

Is there any objective reason for the names to be backward from the operations that construct them or is it just some naming convention that stuck from some example lost in obscurity?

I'm asking this question because being that it's unintuitive I find it's always hard to remember the order. If `worldViewProjection` equaled `world * view * projection` it would be easy since the name matches the order. I'm hoping there's some other objective reason that might help remember vs just remembering always multiply backward from the order of the parts of the commonly used names.

**Tags:** transformations, glsl, hlsl

> **Comments:**
> **username_0**: See code above. We are not multiplying by world first. Even if you have a matrix stack it's always projection first if you were to put it in the stack. Maybe in your mind we are but in code we are not. If you were to write `a = b + c + d` no one would describe that as adding `d` first  
> **username_1**: Personally I would prefer more explicit naming conventions. For example:    `worldToScreen = worldToView * viewToScreen` , or    `screenPosition = worldToScreen * worldPosition` ...  
> **username_2**: Can we just blame this on the fact we multiply right-to-left while reading from left-to-right ?  

---

## 2 answers

### Answer by username_3 on 2016-07-19. Score: 7

I think the naming order is intuitive because it is in reading order (left to right), e.g., worldViewProjection means that your point/direction is first multiplied by the world matrix, then the view matrix, and then the projection matrix. In this manner, you know the correct multiplication order by just reading the variable name and you do not have to think about mathematics at all. In your case, I think the problem is that your intuition seems to be focused on how you write the equations on paper or code.

The idea that a point is a column vector and matrices are multiplied on the left is also just a mathematical convention that you are used. You can use a row vector and multiply on the right by the transpose matrix, and the math is exactly the same, but would imply a reverse writing order in compound transformations. Some people just prefer one notation over the other.

I have read some old computer graphics books that use row vectors as points/directions, but it seems that most modern books have converged on using column vectors. IMHO, maybe this change during the years is one of the sources of confusion for so many new CG students.

For instance, if you choose to represent points as row vectors you would write something like this in your code: **new\_point = point \* world \* view \* projection**. On the other hand, if you use column vectors you would write this: **new\_point = projection \* view \* world \* point**. The important thing is that these matrices must not be the same, that is, the world matrix in the first code is the transpose of the world matrix in the second code, and the same is true for the others. As you can see, if you choose one math convention over the other, this will probably have influence on your naming conventions while writing your code.


---

### Answer by username_4 on 2016-07-20. Score: 5

The order is arbitrary, but if you want to be compatible with physics textbooks then your notation is mostly set. The difference is that you seem to think that its more natural to observe the systen on the outside (and for graphics pipe devs its often so, not for modeler). For a mathematician it is more natural to think from local coordinates out. There are several reasons for this but mathematician seem to want to reduce this to functional form if you were to transform a value x through multiple functions you would get:

$$
h(g(f(x)))
$$

or sometimes

$$
(h \circ g \circ f)(x)
$$

This quite literary means transform x to f to g to h. So it is natural for a mathematician/physicist and some programmers to read the operations inside out simplybbecause this ties in better with the notation you were teached in early calculus. This way your operational order matches also other branches of mathematical notation. Since most math and physics textbooks take this approach you probably should too.

The other reason is that your modeling elements lie on the outside of your data. But obviously you are free to transpose your vectors and then your order is opposite. It is up to you to define meaning to your math. This because there is a rule that follows from how matrices are defined that states:

$$
(A \cdot B)^T = B^T \cdot A^T
$$

It is easily shown that longer chains just reverse the entire chain by recursing this forumula.

It is good to remeber that the order inside the vectors are arbitrary as well as calculation order. There is no reason for the vector to be defined in X, Y, Z, W order we could define the matrices and vectors in any order even a slightly cryptic X, W, Z, Y order. So rember the modeling convention is not somehow set in stone. Students would often want it to be, because that would mean not needing to understand as much, but it does not have to be. Matrices just enable you to model arbitrary vectors with unified math notation.


---

