5
\$\begingroup\$

I'm using a 3d game engine, that uses a 4x4 matrix to modify the camera projection.

The matrix is in the regular 4x4 format:

 r r r  x
 r r r  y
 r r r  z
 - - -  zoom

The description for the matrix class says:

A transformation matrix. Matrices are pre-multiplication, as in: x' = M*x.

What does this mean?

\$\endgroup\$
2
  • \$\begingroup\$ There is no regular 4x4 matrix format, only row- and column-major form. Your example is in column-major form, as used for instance in OpenGL. \$\endgroup\$ Jan 14 '12 at 16:41
  • \$\begingroup\$ Check this link. It's explained in detail: scratchapixel.com/lessons/3d-basic-lessons/lesson-4-geometry/… \$\endgroup\$
    – user14697
    Mar 24 '12 at 23:05
4
\$\begingroup\$

It's not saying the matrices are pre-multiplied but rather that they are (read use) pre-multiplication.

This basically specifies the correct order of multiplication when using them, such that when multiplying a matrix by a vector, the matrix needs comes first.

In other words, this:

result = matrix * vector

Instead of:

result = vector * matrix
\$\endgroup\$
6
\$\begingroup\$

Pre- or post-multiplication just defines the order of operations how the member of that matrix and vector are multiplied, its purely a notational convention.

The common operations in 3D graphics are post-multiplying a row-vector with column-major matrices (OpenGL) and pre-multiplying a column-vector with row-major matrices (DirectX).

Both are basically the same operations with the same results, just the notational convention is different.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .