Model Matrix Transformations: A Change-of-Coordinates Perspective
The model matrix is a fundamental transformation in computer graphics that converts local object coordinates to world space. We examine the mathematical foundations of model matrices through the lens of change-of-coordinates transformations, with particular focus on rotational components. We demonstrate that rotation transformations can be conceptualized in two equivalent ways: As direct matrix operations on basis vectors, or as coordinate system changes between orthonormal bases.
A model matrix describes the size, position, and orientation of an object relative to world coordinates [๐VB15, p. 139]. It can be understood as a change-of-coordinates matrix that transforms local coordinates [u]Mโ relative to a local basis M into world coordinates with basis W.
In the following, we will elaborate on the relationship between the rotational component of the model matrix and change-of-coordinates matrices.
We assume that the basis M shares the same origin as W. If this is not the case, an additional translation must be applied, which is omitted below for the sake of simplicity.
A model matrix can be understood as a change-of-coordinates matrix:
This allows us to express any local vector in world coordinates:
[u]ฮตโ=WโMPโ[u]Mโ
If we want to rotate the model - and thus all coordinates expressed relative to it - we use a rotation matrix R (relative to world coordinates).
When multiplied by a vector v, we thus obtain a rotated vector
vโฒ=Rv
Likewise, the rotation can be applied to the basis vectors of the model matrix, thereby rotating the entire model basis - and thus the model:
This derivation shows an important point that is commonly seen in various software libraries for matrix multiplication (e.g. glm):
the model matrix is rotated first, and then the vector is transformed
the vector is transformed first, and then rotated.
Due to the associativity of matrix multiplication, both approaches are equivalent and lead to the same result.
Passive Rotation and the Composition of Transformationsโ
Alternatively, the rotation can also be understood as a change of basis. If R contains the orthonormal basis vectors r1โโ,r2โโ,r3โโ as its columns, then the following holds: